summaryrefslogtreecommitdiff
path: root/app/serializers/analytics_stage_entity.rb
diff options
context:
space:
mode:
authorJames Lopez <james@jameslopez.es>2016-11-21 17:15:25 +0100
committerJames Lopez <james@jameslopez.es>2017-01-17 11:32:54 +0100
commita998276223510ceee67f686dfc3ef536c0252c5a (patch)
treedbc30d5ef3b26fcad6c856c7741d8d32cccf7b23 /app/serializers/analytics_stage_entity.rb
parent3268e3779166c7ddf47ecc0d78397cd75cf2f0e8 (diff)
downloadgitlab-ce-a998276223510ceee67f686dfc3ef536c0252c5a.tar.gz
added analytics stage serializer and moved some info to the stage classes from the controller
Diffstat (limited to 'app/serializers/analytics_stage_entity.rb')
-rw-r--r--app/serializers/analytics_stage_entity.rb12
1 files changed, 12 insertions, 0 deletions
diff --git a/app/serializers/analytics_stage_entity.rb b/app/serializers/analytics_stage_entity.rb
new file mode 100644
index 00000000000..72a587c8c1d
--- /dev/null
+++ b/app/serializers/analytics_stage_entity.rb
@@ -0,0 +1,12 @@
+class AnalyticsStageEntity < Grape::Entity
+ include EntityDateHelper
+
+ expose :stage, as: :title do |object|
+ object[:stage].to_s.capitalize
+ end
+ expose :description
+
+ expose :median, as: :value do |stage|
+ stage[:median] && !stage[:median].zero? ? distance_of_time_in_words(stage[:median]) : nil
+ end
+end