diff options
Diffstat (limited to 'app/models/projects')
-rw-r--r-- | app/models/projects/build_artifacts_size_refresh.rb | 11 | ||||
-rw-r--r-- | app/models/projects/topic.rb | 8 |
2 files changed, 16 insertions, 3 deletions
diff --git a/app/models/projects/build_artifacts_size_refresh.rb b/app/models/projects/build_artifacts_size_refresh.rb index dee4afdefa6..e66e1d5b42f 100644 --- a/app/models/projects/build_artifacts_size_refresh.rb +++ b/app/models/projects/build_artifacts_size_refresh.rb @@ -2,6 +2,7 @@ module Projects class BuildArtifactsSizeRefresh < ApplicationRecord + include AfterCommitQueue include BulkInsertSafe STALE_WINDOW = 2.hours @@ -52,6 +53,8 @@ module Projects scope :remaining, -> { with_state(:created, :pending).or(stale) } scope :processing_queue, -> { remaining.order(state: :desc) } + after_destroy :schedule_namespace_aggregation_worker + def self.enqueue_refresh(projects) now = Time.zone.now @@ -93,5 +96,13 @@ module Projects def started? !created? end + + private + + def schedule_namespace_aggregation_worker + run_after_commit do + Namespaces::ScheduleAggregationWorker.perform_async(project.namespace_id) + end + end end end diff --git a/app/models/projects/topic.rb b/app/models/projects/topic.rb index b0f138714a0..3155eede2bd 100644 --- a/app/models/projects/topic.rb +++ b/app/models/projects/topic.rb @@ -18,9 +18,11 @@ module Projects scope :without_assigned_projects, -> { where(total_projects_count: 0) } scope :order_by_non_private_projects_count, -> { order(non_private_projects_count: :desc).order(id: :asc) } scope :reorder_by_similarity, -> (search) do - order_expression = Gitlab::Database::SimilarityScore.build_expression(search: search, rules: [ - { column: arel_table['name'] } - ]) + order_expression = Gitlab::Database::SimilarityScore.build_expression( + search: search, + rules: [ + { column: arel_table['name'] } + ]) reorder(order_expression.desc, arel_table['non_private_projects_count'].desc, arel_table['id']) end |