Commit d55b077661c7d225711d772cee1717a81728cc09

Authored by Nick Recobra
1 parent e012272c
Exists in master and in 1 other branch production

Memoizing issue templates.

Showing 1 changed file with 12 additions and 2 deletions   Show diff stats
app/models/issue_tracker.rb
... ... @@ -28,7 +28,7 @@ class IssueTracker
28 28 RedmineClient::Issue.site = account + "/projects/:project_id"
29 29 issue = RedmineClient::Issue.new(:project_id => project_id)
30 30 issue.subject = issue_title err
31   - issue.description = ERB.new(File.read(Rails.root + "app/views/errs/redmine_body.txt.erb").gsub(/^\s*/, '')).result(binding)
  31 + issue.description = self.class.redmine_body_template.result(binding)
32 32 issue.save!
33 33 err.update_attribute :issue_link, "#{RedmineClient::Issue.site.to_s.sub(/#{RedmineClient::Issue.site.path}$/, '')}#{RedmineClient::Issue.element_path(issue.id, :project_id => project_id)}".sub(/\.xml$/, '')
34 34 end
... ... @@ -43,7 +43,7 @@ class IssueTracker
43 43 ticket = Lighthouse::Ticket.new(:project_id => project_id)
44 44 ticket.title = issue_title err
45 45  
46   - ticket.body = ERB.new(File.read(Rails.root + "app/views/errs/lighthouseapp_body.txt.erb").gsub(/^\s*/, '')).result(binding)
  46 + ticket.body = self.class.lighthouseapp_body_template.result(binding)
47 47  
48 48 ticket.tags << "errbit"
49 49 ticket.save!
... ... @@ -65,4 +65,14 @@ class IssueTracker
65 65 errors.add(:base, message)
66 66 end
67 67 end
  68 +
  69 + class << self
  70 + def lighthouseapp_body_template
  71 + @@lighthouseapp_body_template ||= ERB.new(File.read(Rails.root + "app/views/errs/lighthouseapp_body.txt.erb").gsub(/^\s*/, ''))
  72 + end
  73 +
  74 + def redmine_body_template
  75 + @@redmine_body_template ||= ERB.new(File.read(Rails.root + "app/views/errs/redmine_body.txt.erb").gsub(/^\s*/, ''))
  76 + end
  77 + end
68 78 end
... ...