blob: c642809a792e5072126abf4616ac6efe6e415bae (
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
|
# frozen_string_literal: true
module Gitlab
module CycleAnalytics
class Updater
def self.update!(*args)
new(*args).update!
end
def initialize(event_result, from:, to:, klass:)
@event_result = event_result
@klass = klass
@from = from
@to = to
end
def update!
@event_result.each do |event|
event[@to] = items[event.delete(@from).to_i].first
end
end
def result_ids
@event_result.map { |event| event[@from] }
end
def items
@items ||= @klass.find(result_ids).group_by { |item| item['id'] }
end
end
end
end
|