Sha256: 6f8e1b744e274cea0702bfa16be965381a803c90ef44e14d8fdef60581c889a3
Contents?: true
Size: 1.78 KB
Versions: 1
Compression:
Stored size: 1.78 KB
Contents
class ProblemPresenter include ActionView::Helpers::DateHelper include CommitHelper attr_reader :project, :problems def initialize(project, problems) @project = project @problems = problems end def as_json(*args) Houston.benchmark "[problem_presenter] Prepare JSON" do @problems.map(&method(:problem_to_json)) end end def problem_to_json(problem) { id: problem.id, ticketId: problem.ticket.try(:id), ticketUrl: (@project.ticket_tracker.ticket_url(problem.ticket) if problem.ticket), ticketNumber: problem.ticket.try(:number), token: problem.err_ids.first, url: problem.url, message: problem.message, where: problem.where, noticesCount: problem.notices_count, comments: problem.comments, firstNotice: present_notice(problem.first_notice_at, problem.first_notice_commit, problem.first_notice_environment), lastNotice: present_notice( problem.last_notice_at, problem.last_notice_commit, problem.last_notice_environment) } end def present_notice(time, sha, environment_name) { at: time, ago: distance_of_time_in_words(time, Time.now).gsub("about ", "") + " ago", commit: (format_sha(sha) unless sha.blank?), commitUrl: (project.repo.commit_url(sha) if project.repo.respond_to?(:commit_url)), release: present_release(sha, environment_name) } end def present_release(sha, environment_name) release = @project.releases.where(["LOWER(environment_name) = ?", environment_name.downcase]).find_by_commit1(sha) if environment_name && !sha.blank? { url: "/projects/#{@project.slug}/environments/#{environment_name}/releases/#{release.id}", at: release.created_at.strftime("%b %d"), environment: environment_name.humanize } if release end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
houston-core-0.5.0.beta1 | app/presenters/problem_presenter.rb |