summaryrefslogtreecommitdiff
path: root/lib/gitlab/background_migration/calculate_wiki_sizes.rb
blob: 886c41a2b9de3312f72201c39097462757bafc6e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# frozen_string_literal: true
# rubocop:disable Style/Documentation

module Gitlab
  module BackgroundMigration
    class CalculateWikiSizes
      def perform(start_id, stop_id)
        ::ProjectStatistics.where(wiki_size: nil)
          .where(id: start_id..stop_id)
          .includes(project: [:route, :group, namespace: [:owner]]).find_each do |statistics|
          statistics.refresh!(only: [:wiki_size])
        rescue => e
          Rails.logger.error "Failed to update wiki statistics. id: #{statistics.id} message: #{e.message}"
        end
      end
    end
  end
end