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
|
|
|
|
|
2018-02-12 12:24:42 +00:00
|
|
|
expose :median, as: :value do |stage|
|
2018-02-21 12:13:56 +00:00
|
|
|
# median returns a BatchLoader instance which we first have to unwrap by using to_i
|
|
|
|
!stage.median.to_i.zero? ? distance_of_time_in_words(stage.median) : nil
|
2016-11-21 16:15:25 +00:00
|
|
|
end
|
|
|
|
end
|