mirror of
https://0xacab.org/sutty/sutty
synced 2024-11-28 05:26:22 +00:00
Merge branch 'blazer' into panel.sutty.nl
This commit is contained in:
commit
d5db2c2e20
1 changed files with 32 additions and 13 deletions
|
@ -24,6 +24,7 @@ class UriCollectionJob < PeriodicJob
|
|||
# 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]
|
||||
|
||||
# Recorremos todos los hostnames y uris posibles y luego agrupamos
|
||||
# recursivamente para no tener que recalcular, asumiendo que es más
|
||||
|
@ -33,11 +34,31 @@ class UriCollectionJob < PeriodicJob
|
|||
site.hostnames.each do |host|
|
||||
break if stop?
|
||||
|
||||
host_dimensions = { host: host }
|
||||
|
||||
# Las URIs son la fuente de verdad de las visitas, porque son las
|
||||
# que indican las páginas y recursos descargables, el resto son
|
||||
# imágenes, CSS, JS y tipografías que no nos aportan números
|
||||
# significativos.
|
||||
uris.each do |uri|
|
||||
break if stop?
|
||||
|
||||
rollup('host|uri', beginning, host: host, uri: uri)
|
||||
reduce_rollup('host|uri', beginning, host: host, uri: uri)
|
||||
name = 'host|uri'
|
||||
dimensions = { host: host, uri: uri }
|
||||
|
||||
rollup(name, beginning, **dimensions)
|
||||
reduce_rollup(name, beginning, **dimensions)
|
||||
|
||||
columns.each do |column|
|
||||
# Obtener orígenes de visitas por host
|
||||
AccessLog.where(**host_dimensions).distinct(column).pluck(column).each do |value|
|
||||
name = "#{name}|#{column}"
|
||||
dimensions[column] = value
|
||||
|
||||
rollup(name, beginning, **dimensions)
|
||||
reduce_rollup(name, beginning, **dimensions)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# Reducir todas las visitas a cantidad de visitas por host
|
||||
|
@ -45,23 +66,21 @@ class UriCollectionJob < PeriodicJob
|
|||
new_name: 'host',
|
||||
interval_previous: starting_interval,
|
||||
interval: starting_interval,
|
||||
dimensions: { host: host },
|
||||
dimensions: host_dimensions,
|
||||
beginning: beginning)
|
||||
|
||||
# Acumular por mes y año
|
||||
reduce_rollup('host', beginning, host: host)
|
||||
reduce_rollup('host', beginning, **host_dimensions)
|
||||
|
||||
columns = %i[http_referer geoip2_data_country_name]
|
||||
columns.each do |column|
|
||||
# Obtener orígenes de visitas por host
|
||||
AccessLog.where(host: host).distinct(column).pluck(column).each do |value|
|
||||
name = "host|#{column}"
|
||||
dimensions = { host: host }
|
||||
dimensions[column] = value
|
||||
recursive_rollup(name: "host|uri|#{column}",
|
||||
new_name: "host|#{column}",
|
||||
interval_previous: starting_interval,
|
||||
interval: starting_interval,
|
||||
dimensions: host_dimensions,
|
||||
beginning: beginning)
|
||||
|
||||
rollup(name, beginning, **dimensions)
|
||||
reduce_rollup(name, beginning, **dimensions)
|
||||
end
|
||||
reduce_rollup("host|#{column}", beginning, **host_dimensions)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue