batch_root_storage_statistics_loader.rb 581 字节
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13
# 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
B
Brett Walker 已提交
14
          BatchLoader::GraphQL.for(namespace_id).batch do |namespace_ids, loader|
15 16 17 18 19 20 21 22 23
            Namespace::RootStorageStatistics.for_namespace_ids(namespace_ids).each do |statistics|
              loader.call(statistics.namespace_id, statistics)
            end
          end
        end
      end
    end
  end
end