summaryrefslogtreecommitdiff
path: root/lib/gitlab/graphql/loaders/batch_root_storage_statistics_loader.rb
blob: a0312366d664e65ab6586b5cd97de536c8131b0d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# frozen_string_literal: true

module Gitlab
  module Graphql
    module Loaders
      class BatchRootStorageStatisticsLoader
        attr_reader :namespace_id

        def initialize(namespace_id)
          @namespace_id = namespace_id
        end

        def find
          BatchLoader.for(namespace_id).batch do |namespace_ids, loader|
            Namespace::RootStorageStatistics.for_namespace_ids(namespace_ids).each do |statistics|
              loader.call(statistics.namespace_id, statistics)
            end
          end
        end
      end
    end
  end
end