Class: ChronoForge::Dashboard::BranchesPresenter

Inherits:
Object
  • Object
show all
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$<name> and merge$<names>) — a tiny set — and derives each branch’s merge state from the merge logs (the core doesn’t persist a “merged” flag).

Defined Under Namespace

Classes: Merge

Instance Method Summary collapse

Constructor Details

#initialize(workflow) ⇒ BranchesPresenter

Returns a new instance of BranchesPresenter.



13
# File 'app/presenters/chrono_forge/dashboard/branches_presenter.rb', line 13

def initialize(workflow) = @workflow = workflow

Instance Method Details

#any?Boolean

Returns:

  • (Boolean)


15
# File 'app/presenters/chrono_forge/dashboard/branches_presenter.rb', line 15

def any? = branch_logs.any?

#branchesObject



17
18
19
20
21
# File 'app/presenters/chrono_forge/dashboard/branches_presenter.rb', line 17

def branches
  @branches ||= branch_logs
    .sort_by(&:step_name)
    .map { |log| BranchPresenter.new(log, merge_states[StepNameParser.parse(log.step_name).name]) }
end

#mergesObject

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.



25
26
27
28
29
# File 'app/presenters/chrono_forge/dashboard/branches_presenter.rb', line 25

def merges
  @merges ||= merge_logs
    .map { |log| Merge.new(StepNameParser.parse(log.step_name).name.split(","), log.completed? ? :merged : :merging, log.started_at) }
    .sort_by { |m| [m.merging? ? 0 : 1, m.started_at || Time.current] }
end