mirror of
https://0xacab.org/sutty/sutty
synced 2024-11-27 19:46:22 +00:00
Merge branch 'blazer' into panel.sutty.nl
This commit is contained in:
commit
f807bb4891
1 changed files with 10 additions and 5 deletions
|
@ -21,10 +21,12 @@ class UriCollectionJob < PeriodicJob
|
|||
def perform(site_id:, once: true)
|
||||
@site = Site.find site_id
|
||||
|
||||
# Obtener el principio del intervalo anterior
|
||||
beginning = beginning_of_interval
|
||||
# Recordar la última vez que se corrió la tarea
|
||||
stat = site.stats.create! name: STAT_NAME
|
||||
beginning = beginning_of_interval
|
||||
columns = %i[http_referer geoip2_data_country_name]
|
||||
# Columnas a agrupar
|
||||
columns = %i[http_referer geoip2_data_country_name].zip([nil]).to_h
|
||||
|
||||
# Recorremos todos los hostnames y uris posibles y luego agrupamos
|
||||
# recursivamente para no tener que recalcular, asumiendo que es más
|
||||
|
@ -35,6 +37,9 @@ class UriCollectionJob < PeriodicJob
|
|||
break if stop?
|
||||
|
||||
host_dimensions = { host: host }
|
||||
columns.each_key do |column|
|
||||
columns[column] = AccessLog.where(**host_dimensions).distinct(column).pluck(column)
|
||||
end
|
||||
|
||||
# Las URIs son la fuente de verdad de las visitas, porque son las
|
||||
# que indican las páginas y recursos descargables, el resto son
|
||||
|
@ -49,9 +54,9 @@ class UriCollectionJob < PeriodicJob
|
|||
rollup(name, beginning, **dimensions)
|
||||
reduce_rollup(name, beginning, **dimensions)
|
||||
|
||||
columns.each do |column|
|
||||
columns.each_pair do |column, values|
|
||||
# Obtener orígenes de visitas por host
|
||||
AccessLog.where(**host_dimensions).distinct(column).pluck(column).each do |value|
|
||||
values.each do |value|
|
||||
column_name = "host|uri|#{column}"
|
||||
dimensions[column] = value
|
||||
|
||||
|
@ -71,7 +76,7 @@ class UriCollectionJob < PeriodicJob
|
|||
# Acumular por mes y año
|
||||
reduce_rollup('host', beginning, **host_dimensions)
|
||||
|
||||
columns.each do |column|
|
||||
columns.each_key do |column|
|
||||
square_rollup(name: "host|uri|#{column}",
|
||||
new_name: "host|#{column}",
|
||||
interval: starting_interval,
|
||||
|
|
Loading…
Reference in a new issue