mirror of
https://github.com/mastodon/mastodon.git
synced 2024-08-20 21:08:15 -07:00
Clean up query generation in tag server measure report
This commit is contained in:
parent
598ae4f2da
commit
f27c1a587d
1 changed files with 19 additions and 2 deletions
|
@ -14,11 +14,11 @@ class Admin::Metrics::Measure::TagServersMeasure < Admin::Metrics::Measure::Base
|
||||||
protected
|
protected
|
||||||
|
|
||||||
def perform_total_query
|
def perform_total_query
|
||||||
tag.statuses.where('statuses.id BETWEEN ? AND ?', Mastodon::Snowflake.id_at(@start_at, with_random: false), Mastodon::Snowflake.id_at(@end_at, with_random: false)).joins(:account).count('distinct accounts.domain')
|
domain_tag_count id_range(@start_at, @end_at)
|
||||||
end
|
end
|
||||||
|
|
||||||
def perform_previous_total_query
|
def perform_previous_total_query
|
||||||
tag.statuses.where('statuses.id BETWEEN ? AND ?', Mastodon::Snowflake.id_at(@start_at - length_of_period, with_random: false), Mastodon::Snowflake.id_at(@end_at - length_of_period, with_random: false)).joins(:account).count('distinct accounts.domain')
|
domain_tag_count id_range(@start_at, @end_at, length_of_period)
|
||||||
end
|
end
|
||||||
|
|
||||||
def sql_array
|
def sql_array
|
||||||
|
@ -60,4 +60,21 @@ class Admin::Metrics::Measure::TagServersMeasure < Admin::Metrics::Measure::Base
|
||||||
def params
|
def params
|
||||||
@params.permit(:id)
|
@params.permit(:id)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def domain_tag_count(range)
|
||||||
|
tag
|
||||||
|
.statuses
|
||||||
|
.where(id: range)
|
||||||
|
.joins(:account)
|
||||||
|
.distinct
|
||||||
|
.count(Account.arel_table[:domain])
|
||||||
|
end
|
||||||
|
|
||||||
|
def id_range(starting, ending, offset = 0)
|
||||||
|
id_from(starting - offset)..id_from(ending - offset)
|
||||||
|
end
|
||||||
|
|
||||||
|
def id_from(time)
|
||||||
|
Mastodon::Snowflake.id_at(time, with_random: false)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue