blob: da54ad4de0eb75c517350c955e94a6c18ecb1d4b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
# 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)
format_results(graph, results)
end
private
def format_results(name, results)
{
id: name,
keys: results.keys,
values: results.values
}
end
def product_analytics_events
@project.product_analytics_events
end
end
end
|