diff --git a/app/jobs/uri_collection_job.rb b/app/jobs/uri_collection_job.rb new file mode 100644 index 0000000..79b8364 --- /dev/null +++ b/app/jobs/uri_collection_job.rb @@ -0,0 +1,17 @@ +# frozen_string_literal: true + +# Procesar una lista de URIs para una lista de dominios. Esto nos +# permite procesar estadísticas a demanada. +class UriCollectionJob < ApplicationJob + def perform(hostnames:, file:) + uris = File.read(file).split("\n") + + hostnames.each do |hostname| + uris.each do |uri| + break if File.exist? Rails.root.join('tmp', 'uri_collection_job_stop') + + AccessLog.where(host: hostname, uri: uri).completed_requests.non_robots.group(:host, :uri).rollup('host|uri', interval: 'day') + end + end + end +end