gitlab-org--gitlab-foss/app/serializers/analytics_stage_entity.rb

17 lines
491 B
Ruby
Raw Normal View History

# 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
2019-05-23 11:23:38 +00:00
# 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