diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-03-17 06:08:05 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-03-17 06:08:05 +0300 |
commit | e6ac8e40c2c0fa317c319469d5102eec8be7becd (patch) | |
tree | 409145db12c32c6d3e342aeada2e3015d631dc07 /app/models/analytics | |
parent | 149436d2a55408accbf67f9301c0bfa3c6706fe6 (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 | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/app/models/analytics/cycle_analytics/aggregation.rb b/app/models/analytics/cycle_analytics/aggregation.rb index 279938511fd..44d2dc369f7 100644 --- a/app/models/analytics/cycle_analytics/aggregation.rb +++ b/app/models/analytics/cycle_analytics/aggregation.rb @@ -7,7 +7,7 @@ class Analytics::CycleAnalytics::Aggregation < ApplicationRecord validates :incremental_runtimes_in_seconds, :incremental_processed_records, :last_full_run_runtimes_in_seconds, :last_full_run_processed_records, presence: true, length: { maximum: 10 }, allow_blank: true - scope :priority_order, -> { order('last_incremental_run_at ASC NULLS FIRST') } + scope :priority_order, -> (column_to_sort = :last_incremental_run_at) { order(arel_table[column_to_sort].asc.nulls_first) } scope :enabled, -> { where('enabled IS TRUE') } def estimated_next_run_at @@ -55,17 +55,17 @@ class Analytics::CycleAnalytics::Aggregation < ApplicationRecord connection.select_value("(#{max})") end - def self.load_batch(last_run_at, batch_size = 100) + def self.load_batch(last_run_at, column_to_query = :last_incremental_run_at, batch_size = 100) last_run_at_not_set = Analytics::CycleAnalytics::Aggregation .enabled - .where(last_incremental_run_at: nil) - .priority_order + .where(column_to_query => nil) + .priority_order(column_to_query) .limit(batch_size) last_run_at_before = Analytics::CycleAnalytics::Aggregation .enabled - .where('last_incremental_run_at < ?', last_run_at) - .priority_order + .where(arel_table[column_to_query].lt(last_run_at)) + .priority_order(column_to_query) .limit(batch_size) Analytics::CycleAnalytics::Aggregation |