diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/gitlab/cycle_analytics/events.rb | 7 | ||||
-rw-r--r-- | lib/gitlab/cycle_analytics/events_fetcher.rb | 14 |
2 files changed, 20 insertions, 1 deletions
diff --git a/lib/gitlab/cycle_analytics/events.rb b/lib/gitlab/cycle_analytics/events.rb index ea8e78d7ab7..739c8772080 100644 --- a/lib/gitlab/cycle_analytics/events.rb +++ b/lib/gitlab/cycle_analytics/events.rb @@ -34,6 +34,13 @@ module Gitlab end end + def test_events + @fetcher.fetch_test_events.each do |event| + event['total_time'] = distance_of_time_in_words(event['total_time'].to_f) + event['pipeline'] = ::Ci::Pipeline.find_by_id(event['ci_commit_id']) # we may not have a pipeline + end + end + private def first_time_reference_commit(commits, event) diff --git a/lib/gitlab/cycle_analytics/events_fetcher.rb b/lib/gitlab/cycle_analytics/events_fetcher.rb index cb61cda200d..d12161be0d3 100644 --- a/lib/gitlab/cycle_analytics/events_fetcher.rb +++ b/lib/gitlab/cycle_analytics/events_fetcher.rb @@ -36,7 +36,7 @@ module Gitlab base_query = base_query_for(:code) diff_fn = subtract_datetimes_diff(base_query, issue_metrics_table[:first_mentioned_in_commit_at], - issue_table[:created_at]) + mr_table[:created_at]) query = base_query.join(user_table).on(issue_table[:author_id].eq(user_table[:id])). project(extract_epoch(diff_fn).as('total_time'), *code_projections). @@ -45,6 +45,18 @@ module Gitlab execute(query) end + def fetch_test_events + base_query = base_query_for(:code) + diff_fn = subtract_datetimes_diff(base_query, + mr_metrics_table[:latest_build_started_at], + mr_metrics_table[:latest_build_finished_at]) + + query = base_query.project(extract_epoch(diff_fn).as('total_time'), mr_metrics_table[:ci_commit_id]). + order(mr_table[:created_at].desc) + + execute(query) + end + private def issue_attributes |