Class: ChronoForge::Dashboard::BranchesPresenter
- Inherits:
-
Object
- Object
- ChronoForge::Dashboard::BranchesPresenter
- Defined in:
- app/presenters/chrono_forge/dashboard/branches_presenter.rb
Overview
A workflow's branches for its detail page. Loads only the coordination logs
(branch$
Defined Under Namespace
Classes: Merge
Instance Method Summary collapse
- #any? ⇒ Boolean
- #branches ⇒ Object
-
#initialize(workflow) ⇒ BranchesPresenter
constructor
A new instance of BranchesPresenter.
-
#merges ⇒ Object
The merge joins on this workflow, in-progress first.
Constructor Details
#initialize(workflow) ⇒ BranchesPresenter
Returns a new instance of BranchesPresenter.
24 |
# File 'app/presenters/chrono_forge/dashboard/branches_presenter.rb', line 24 def initialize(workflow) = @workflow = workflow |
Instance Method Details
#any? ⇒ Boolean
26 |
# File 'app/presenters/chrono_forge/dashboard/branches_presenter.rb', line 26 def any? = branch_logs.any? |
#branches ⇒ Object
28 29 30 31 32 |
# File 'app/presenters/chrono_forge/dashboard/branches_presenter.rb', line 28 def branches @branches ||= branch_logs .sort_by(&:step_name) .map { |log| BranchPresenter.new(log, merge_states[StepNameParser.parse(log.step_name).name]) } end |
#merges ⇒ Object
The merge joins on this workflow, in-progress first. A long-pending merge with no blocked children is the sign of a dropped BranchMergeJob poller.
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'app/presenters/chrono_forge/dashboard/branches_presenter.rb', line 36 def merges @merges ||= merge_logs.map { |log| names = StepNameParser.parse(log.step_name).name.split(",") poll = merge_poll(names) rate, eta = merge_throughput(names) Merge.new( names, log.completed? ? :merged : :merging, log.started_at, parse_time(poll&.dig("last_polled_at")), parse_time(poll&.dig("next_poll_at")), poll&.dig("polls"), rate, eta ) }.sort_by { |m| [m.merging? ? 0 : 1, m.started_at || Time.current] } end |