summaryrefslogtreecommitdiff
path: root/lib/gitlab/cycle_analytics/staging_event_fetcher.rb
blob: ea98e211ad6b57c99bf11b63761d6ec6f2f2ccb8 (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
module Gitlab
  module CycleAnalytics
    class StagingEventFetcher < BaseEventFetcher
      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 custom_query(base_query)
        base_query.join(build_table).on(mr_metrics_table[:pipeline_id].eq(build_table[:commit_id]))
      end

      private

      def serialize(event)
        AnalyticsBuildSerializer.new.represent(event['build']).as_json
      end
    end
  end
end