2019-07-02 10:44:39 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module Namespaces
|
|
|
|
class RootStatisticsWorker
|
|
|
|
include ApplicationWorker
|
|
|
|
|
|
|
|
queue_namespace :update_namespace_statistics
|
|
|
|
|
|
|
|
def perform(namespace_id)
|
|
|
|
namespace = Namespace.find(namespace_id)
|
|
|
|
|
2019-08-01 16:14:21 -04:00
|
|
|
return unless namespace.aggregation_scheduled?
|
2019-07-02 10:44:39 -04:00
|
|
|
|
|
|
|
Namespaces::StatisticsRefresherService.new.execute(namespace)
|
|
|
|
|
|
|
|
namespace.aggregation_schedule.destroy
|
|
|
|
rescue ::Namespaces::StatisticsRefresherService::RefresherError, ActiveRecord::RecordNotFound => ex
|
|
|
|
log_error(namespace.full_path, ex.message) if namespace
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def log_error(namespace_path, error_message)
|
|
|
|
Gitlab::SidekiqLogger.error("Namespace statistics can't be updated for #{namespace_path}: #{error_message}")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|