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:
Diffstat (limited to 'app/services/product_analytics/build_graph_service.rb')
-rw-r--r--app/services/product_analytics/build_graph_service.rb29
1 files changed, 29 insertions, 0 deletions
diff --git a/app/services/product_analytics/build_graph_service.rb b/app/services/product_analytics/build_graph_service.rb
new file mode 100644
index 00000000000..31f9f093bb9
--- /dev/null
+++ b/app/services/product_analytics/build_graph_service.rb
@@ -0,0 +1,29 @@
+# frozen_string_literal: true
+
+module ProductAnalytics
+ class BuildGraphService
+ def initialize(project, params)
+ @project = project
+ @params = params
+ end
+
+ def execute
+ graph = @params[:graph].to_sym
+ timerange = @params[:timerange].days
+
+ results = product_analytics_events.count_by_graph(graph, timerange)
+
+ {
+ id: graph,
+ keys: results.keys,
+ values: results.values
+ }
+ end
+
+ private
+
+ def product_analytics_events
+ @project.product_analytics_events
+ end
+ end
+end