Welcome to mirror list, hosted at ThFree Co, Russian Federation.

analytics_stage_entity.rb « serializers « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: eb38b90fb183a4314177ac82d047458f600048bc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
# frozen_string_literal: true

class AnalyticsStageEntity < Grape::Entity
  include EntityDateHelper

  expose :title
  expose :name
  expose :legend
  expose :description

  expose :project_median, as: :value do |stage|
    # median returns a BatchLoader instance which we first have to unwrap by using to_f
    # we use to_f to make sure results below 1 are presented to the end-user
    stage.project_median.to_f.nonzero? ? distance_of_time_in_words(stage.project_median) : nil
  end
end