gitlab-org--gitlab-foss/lib/gitlab/cycle_analytics/events_fetcher.rb
James Lopez eccb6a5e92 Refactored test events
Now test events return the builds instead a list of pipelines to avoid calling pipeline.builds per each and get the info. Also, added missing fields/data, URLs, and fixed specs in events spec.
2016-11-17 08:22:57 +01:00

38 lines
1.1 KiB
Ruby

module Gitlab
module CycleAnalytics
class EventsFetcher
include MetricsFetcher
def initialize(project:, from:)
@query = EventsQuery.new(project: project, from: from)
end
def fetch(stage:)
custom_query = "#{stage}_custom_query".to_sym
@query.execute(stage) do |base_query|
public_send(custom_query, base_query) if self.respond_to?(custom_query)
end
end
def issue_custom_query(base_query)
base_query.join(user_table).on(issue_table[:author_id].eq(user_table[:id]))
end
alias_method :code_custom_query, :issue_custom_query
alias_method :production_custom_query, :issue_custom_query
def plan_custom_query(base_query)
base_query.join(mr_diff_table).on(mr_diff_table[:merge_request_id].eq(mr_table[:id]))
end
def review_custom_query(base_query)
base_query.join(user_table).on(mr_table[:author_id].eq(user_table[:id]))
end
def test_custom_query(base_query)
base_query.join(build_table).on(mr_metrics_table[:ci_commit_id].eq(build_table[:commit_id]))
end
end
end
end