Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTimothy Andrew <mail@timothyandrew.net>2016-09-17 09:38:23 +0300
committerTimothy Andrew <mail@timothyandrew.net>2016-09-17 09:46:48 +0300
commitedb38d69cc6cffef46b6c7b957ad97ce213173cf (patch)
treee41eae3d77847cd4189ef3c7c21d29543c8fa0ea /app/helpers
parent7d69ff3ddf0fb83c6a1ec02f85b01b454080b647 (diff)
Move cycle analytics JSON generation to a helper.
1. Use a new format, with each stage having a `title`, `description`, and `value.
Diffstat (limited to 'app/helpers')
-rw-r--r--app/helpers/cycle_analytics_helper.rb24
1 files changed, 24 insertions, 0 deletions
diff --git a/app/helpers/cycle_analytics_helper.rb b/app/helpers/cycle_analytics_helper.rb
new file mode 100644
index 00000000000..c49c51642ed
--- /dev/null
+++ b/app/helpers/cycle_analytics_helper.rb
@@ -0,0 +1,24 @@
+module CycleAnalyticsHelper
+ include ActionView::Helpers::DateHelper
+
+ def cycle_analytics_json(cycle_analytics)
+ cycle_analytics_view_data = [[:issue, "Issue", "Time before an issue gets scheduled"],
+ [:plan, "Plan", "Time before an issue starts implementation"],
+ [:code, "Code", "Time until first merge request"],
+ [:test, "Test", "Total test time for all commits/merges"],
+ [:review, "Review", "Time between MR creation and merge/close"],
+ [:staging, "Staging", "From MR merge until deploy to production"],
+ [:production, "Production", "From issue creation until deploy to production"]]
+
+ stats = cycle_analytics_view_data.reduce({}) do |hash, (stage_method, stage_text, stage_description)|
+ hash[stage_method] = {
+ title: stage_text,
+ description: stage_description,
+ value: distance_of_time_in_words(cycle_analytics.send(stage_method))
+ }
+ hash
+ end
+
+ { stats: stats }
+ end
+end