5
0
Fork 0
mirror of https://0xacab.org/sutty/sutty synced 2024-11-22 13:46:20 +00:00

fix: ya no es necesario estimar visitas #16542

This commit is contained in:
f 2024-06-18 10:45:57 -03:00
parent 57377279a5
commit e35fa87464
No known key found for this signature in database

View file

@ -59,9 +59,6 @@ class StatsController < ApplicationController
.order('sum(value) desc') .order('sum(value) desc')
.sum(:value) .sum(:value)
.transform_values(&:to_i) .transform_values(&:to_i)
.transform_values do |v|
v * nodes
end
end end
end end
end end
@ -73,9 +70,6 @@ class StatsController < ApplicationController
stats = rollup_scope.where_dimensions(host: hostnames).multi_series('host', interval: interval).tap do |series| stats = rollup_scope.where_dimensions(host: hostnames).multi_series('host', interval: interval).tap do |series|
series.each do |serie| series.each do |serie|
serie[:name] = serie.dig(:dimensions, 'host') serie[:name] = serie.dig(:dimensions, 'host')
serie[:data].transform_values! do |value|
value * nodes
end
end end
end end
@ -99,9 +93,6 @@ class StatsController < ApplicationController
stats = rollup_scope.where_dimensions(**options).multi_series('host|uri', interval: interval).tap do |series| stats = rollup_scope.where_dimensions(**options).multi_series('host|uri', interval: interval).tap do |series|
series.each do |serie| series.each do |serie|
serie[:name] = serie[:dimensions].slice('host', 'uri').values.join.sub('/index.html', '/') serie[:name] = serie[:dimensions].slice('host', 'uri').values.join.sub('/index.html', '/')
serie[:data].transform_values! do |value|
value * nodes
end
end end
end end
@ -197,21 +188,6 @@ class StatsController < ApplicationController
end end
end end
# Obtiene la cantidad de nodos de Sutty, para poder calcular la
# cantidad de visitas.
#
# Como repartimos las visitas por nodo rotando las IPs en el
# nameserver y los resolvedores de DNS eligen un nameserver
# aleatoriamente, la cantidad de visitas se reparte
# equitativamente.
#
# XXX: Remover cuando podamos centralizar los AccessLog
#
# @return [Integer]
def nodes
@nodes ||= ENV.fetch('NODES', 1).to_i
end
def period def period
@period ||= begin @period ||= begin
p = params.permit(:period_start, :period_end) p = params.permit(:period_start, :period_end)