debian-mirror-gitlab/app/serializers/analytics_stage_entity.rb

17 lines
491 B
Ruby
Raw Normal View History

2018-11-18 11:00:15 +05:30
# frozen_string_literal: true
2017-08-17 22:00:37 +05:30
class AnalyticsStageEntity < Grape::Entity
include EntityDateHelper
expose :title
expose :name
expose :legend
expose :description
2019-10-12 21:52:04 +05:30
expose :project_median, as: :value do |stage|
2019-09-04 21:01:54 +05:30
# 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
2019-10-12 21:52:04 +05:30
stage.project_median.to_f.nonzero? ? distance_of_time_in_words(stage.project_median) : nil
2017-08-17 22:00:37 +05:30
end
end