debian-mirror-gitlab/app/finders/data_transfer/project_data_transfer_finder.rb
2023-06-20 00:43:36 +05:30

25 lines
714 B
Ruby

# frozen_string_literal: true
module DataTransfer
class ProjectDataTransferFinder
def initialize(project:, from:, to:, user:)
@project = project
@from = from
@to = to
@user = user
end
def execute
return ::Projects::DataTransfer.none unless Ability.allowed?(user, :read_usage_quotas, project)
::Projects::DataTransfer
.with_project_between_dates(project, from, to)
.select(:project_id, :date, :repository_egress, :artifacts_egress, :packages_egress, :registry_egress,
"repository_egress + artifacts_egress + packages_egress + registry_egress as total_egress")
end
private
attr_reader :project, :from, :to, :user
end
end