diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-03-15 18:09:10 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-03-15 18:09:10 +0300 |
commit | cb7f766437db0c483adf3c128e35c64237a2ef53 (patch) | |
tree | 0b9bd9fdedad14dd065d14d9198ce080fbbeb8a5 /app/models/analytics | |
parent | 6a9ab27963fc1479fe7c78581b942c8dcce322e5 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/models/analytics')
-rw-r--r-- | app/models/analytics/cycle_analytics/aggregation.rb | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/app/models/analytics/cycle_analytics/aggregation.rb b/app/models/analytics/cycle_analytics/aggregation.rb index d43293f40ea..279938511fd 100644 --- a/app/models/analytics/cycle_analytics/aggregation.rb +++ b/app/models/analytics/cycle_analytics/aggregation.rb @@ -14,7 +14,10 @@ class Analytics::CycleAnalytics::Aggregation < ApplicationRecord return unless enabled return if last_incremental_run_at.nil? - estimation = (last_incremental_run_at - earliest_last_run_at) + average_aggregation_duration + estimation = duration_until_the_next_aggregation_job + + average_aggregation_duration + + (last_incremental_run_at - earliest_last_run_at) + estimation < 1 ? nil : estimation.from_now end @@ -29,6 +32,11 @@ class Analytics::CycleAnalytics::Aggregation < ApplicationRecord private + # The aggregation job is scheduled every 10 minutes: */10 * * * * + def duration_until_the_next_aggregation_job + (10 - (DateTime.current.minute % 10)).minutes.seconds + end + def average_aggregation_duration return 0.seconds if incremental_runtimes_in_seconds.empty? |