5
0
Fork 0
mirror of https://0xacab.org/sutty/sutty synced 2024-11-23 02:16:22 +00:00

Merge branch 'rails' of 0xacab.org:sutty/sutty into issue-15068

This commit is contained in:
f 2024-06-18 16:10:49 -03:00
commit b8c2d1462e
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)