Class: CycleAnalytics::ProjectLevelStageAdapter

Inherits:
Object
  • Object
show all
Defined in:
app/models/cycle_analytics/project_level_stage_adapter.rb

Defined Under Namespace

Classes: ProjectLevelStage

Instance Method Summary collapse

Constructor Details

#initialize(stage, options) ⇒ ProjectLevelStageAdapter

Returns a new instance of ProjectLevelStageAdapter.


9
10
11
12
# File 'app/models/cycle_analytics/project_level_stage_adapter.rb', line 9

def initialize(stage, options)
  @stage = stage
  @options = options
end

Instance Method Details

#as_json(serializer: AnalyticsStageSerializer) ⇒ Object

rubocop: disable CodeReuse/Presenter


15
16
17
18
19
20
21
22
23
24
25
# File 'app/models/cycle_analytics/project_level_stage_adapter.rb', line 15

def as_json(serializer: AnalyticsStageSerializer)
  presenter = Analytics::CycleAnalytics::StagePresenter.new(stage)

  serializer.new.represent(ProjectLevelStage.new(
                             title: presenter.title,
                             description: presenter.description,
                             legend: presenter.legend,
                             name: stage.name,
                             project_median: median
                           ))
end

#eventsObject

rubocop: enable CodeReuse/Presenter


28
29
30
# File 'app/models/cycle_analytics/project_level_stage_adapter.rb', line 28

def events
  data_collector.records_fetcher.serialized_records
end

#medianObject Also known as: project_median


32
33
34
# File 'app/models/cycle_analytics/project_level_stage_adapter.rb', line 32

def median
  data_collector.median.seconds
end