summaryrefslogtreecommitdiff
path: root/app/serializers
diff options
context:
space:
mode:
authorDouwe Maan <douwe@gitlab.com>2017-01-18 18:22:35 +0000
committerDouwe Maan <douwe@gitlab.com>2017-01-18 18:22:35 +0000
commit1cc6d206b5d4cf09bb502a254703f3a2de2dbeb7 (patch)
treed9c1d5c3c56f2416bbc037cca6a7b92b7a7a4f41 /app/serializers
parentcc1e43da3993b6839b4dbe03ae1b8bfb81066666 (diff)
parent1d775d9712d0c493ae171e37fe507f5160cd7d0e (diff)
downloadgitlab-ce-1cc6d206b5d4cf09bb502a254703f3a2de2dbeb7.tar.gz
Merge branch 'fix/refactor-cycle-analytics-stages' into 'master'
Refactor cycle analytics stages (1st iteration) See merge request !7647
Diffstat (limited to 'app/serializers')
-rw-r--r--app/serializers/analytics_stage_entity.rb10
-rw-r--r--app/serializers/analytics_stage_serializer.rb3
-rw-r--r--app/serializers/analytics_summary_entity.rb7
-rw-r--r--app/serializers/analytics_summary_serializer.rb3
4 files changed, 23 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..a559d0850c4
--- /dev/null
+++ b/app/serializers/analytics_stage_entity.rb
@@ -0,0 +1,10 @@
+class AnalyticsStageEntity < Grape::Entity
+ include EntityDateHelper
+
+ expose :title
+ expose :description
+
+ expose :median, as: :value do |stage|
+ stage.median && !stage.median.zero? ? distance_of_time_in_words(stage.median) : nil
+ end
+end
diff --git a/app/serializers/analytics_stage_serializer.rb b/app/serializers/analytics_stage_serializer.rb
new file mode 100644
index 00000000000..613cf6874d8
--- /dev/null
+++ b/app/serializers/analytics_stage_serializer.rb
@@ -0,0 +1,3 @@
+class AnalyticsStageSerializer < BaseSerializer
+ entity AnalyticsStageEntity
+end
diff --git a/app/serializers/analytics_summary_entity.rb b/app/serializers/analytics_summary_entity.rb
new file mode 100644
index 00000000000..91803ec07f5
--- /dev/null
+++ b/app/serializers/analytics_summary_entity.rb
@@ -0,0 +1,7 @@
+class AnalyticsSummaryEntity < Grape::Entity
+ expose :value, safe: true
+
+ expose :title do |object|
+ object.title.pluralize(object.value)
+ end
+end
diff --git a/app/serializers/analytics_summary_serializer.rb b/app/serializers/analytics_summary_serializer.rb
new file mode 100644
index 00000000000..c87a24aa47c
--- /dev/null
+++ b/app/serializers/analytics_summary_serializer.rb
@@ -0,0 +1,3 @@
+class AnalyticsSummarySerializer < BaseSerializer
+ entity AnalyticsSummaryEntity
+end