2018-07-19 18:43:13 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-11-21 16:15:25 +00:00
|
|
|
class AnalyticsStageEntity < Grape::Entity
|
|
|
|
include EntityDateHelper
|
|
|
|
|
2016-12-01 10:21:24 +00:00
|
|
|
expose :title
|
2017-05-04 02:05:38 +00:00
|
|
|
expose :name
|
2017-02-10 08:41:39 +00:00
|
|
|
expose :legend
|
2016-11-21 16:15:25 +00:00
|
|
|
expose :description
|
|
|
|
|
2019-07-04 14:42:31 +00:00
|
|
|
expose :project_median, as: :value do |stage|
|
2019-05-20 21:09:48 +00:00
|
|
|
# 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
|
2019-07-04 14:42:31 +00:00
|
|
|
stage.project_median.to_f.nonzero? ? distance_of_time_in_words(stage.project_median) : nil
|
2016-11-21 16:15:25 +00:00
|
|
|
end
|
|
|
|
end
|