Class: TestingReportTicketPresenter

Inherits:
TicketPresenter show all
Includes:
MarkdownHelper
Defined in:
app/presenters/testing_report_ticket_presenter.rb

Instance Method Summary collapse

Methods included from MarkdownHelper

#markdown, #mdown

Methods included from EmojiHelper

#emojify

Methods included from UrlHelper

#edit_release_path, #edit_release_url, #feature_path, #github_commit_range_url, #github_commit_url, #github_project_url, #github_url?, #goldmine_case_number_url, #link_to_project_feature, #new_release_url, #release_path, #release_url, #releases_path

Constructor Details

#initialize(tickets) ⇒ TestingReportTicketPresenter

Returns a new instance of TestingReportTicketPresenter.



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'app/presenters/testing_report_ticket_presenter.rb', line 4

def initialize(tickets)
  super tickets
    .unclosed
    .fixed
    .includes(:project)
    .includes(:testing_notes => :user)
    .includes(:releases)
  @committers_by_ticket = Commit
    .joins("INNER JOIN commits_tickets ON commits_tickets.commit_id=commits.id")
    .where(["commits_tickets.ticket_id IN (?)", @tickets.pluck(:id)])
    .where(unreachable: false)
    .pluck("commits_tickets.ticket_id", :committer, :committer_email)
    .each_with_object({}) { |(ticket_id, committer_name, committer_email), map|
      (map[ticket_id] ||= Set.new) << TicketCommitter.new(committer_name, committer_email) }
  @released_commits_by_ticket = Commit
    .joins("INNER JOIN commits_tickets ON commits_tickets.commit_id=commits.id")
    .where(["commits_tickets.ticket_id IN (?)", @tickets.pluck(:id)])
    .reachable
    .released
    .select("commits.*, commits_tickets.ticket_id")
    .group_by(&:ticket_id)
end

Instance Method Details

#as_json(*args) ⇒ Object



27
28
29
# File 'app/presenters/testing_report_ticket_presenter.rb', line 27

def as_json(*args)
  super(*args).sort_by { |ticket| ticket[:projectTitle] }
end

#ticket_to_json(ticket) ⇒ Object



31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'app/presenters/testing_report_ticket_presenter.rb', line 31

def ticket_to_json(ticket)
  super.merge(
    committers: @committers_by_ticket.fetch(ticket.id, Set.new).map(&:to_h),
    deployment: ticket.deployment,
    description: mdown(ticket.description),
    priority: ticket.priority,
    verdictsByTester: verdicts_by_tester_index(ticket),
    dueDate: ticket.due_date,
    minPassingVerdicts: ticket.min_passing_verdicts,
    testingNotes: TestingNotePresenter.new(ticket.testing_notes).as_json,
    commits: CommitPresenter.new(@released_commits_by_ticket.fetch(ticket.id, [])).as_json,
    releases: ReleasePresenter.new(ticket.releases).as_json,
    lastReleaseAt: ticket.last_release_at)
end