summaryrefslogtreecommitdiff
path: root/lib/gitlab/cycle_analytics/builds_event_helper.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/gitlab/cycle_analytics/builds_event_helper.rb')
-rw-r--r--lib/gitlab/cycle_analytics/builds_event_helper.rb36
1 files changed, 36 insertions, 0 deletions
diff --git a/lib/gitlab/cycle_analytics/builds_event_helper.rb b/lib/gitlab/cycle_analytics/builds_event_helper.rb
new file mode 100644
index 00000000000..0d6f32fdc6f
--- /dev/null
+++ b/lib/gitlab/cycle_analytics/builds_event_helper.rb
@@ -0,0 +1,36 @@
+# frozen_string_literal: true
+
+module Gitlab
+ module CycleAnalytics
+ module BuildsEventHelper
+ def initialize(*args)
+ @projections = [build_table[:id]]
+ @order = build_table[:created_at]
+
+ super(*args)
+ end
+
+ def fetch
+ Updater.update!(event_result, from: 'id', to: 'build', klass: ::Ci::Build)
+
+ super
+ end
+
+ def events_query
+ base_query.join(build_table).on(mr_metrics_table[:pipeline_id].eq(build_table[:commit_id]))
+
+ super
+ end
+
+ private
+
+ def allowed_ids
+ nil
+ end
+
+ def serialize(event)
+ AnalyticsBuildSerializer.new.represent(event['build'])
+ end
+ end
+ end
+end