mirror of
https://github.com/mastodon/mastodon.git
synced 2024-11-18 12:30:03 +00:00
Align TagServersMeasure
to use WITH
query style similar to others (#29435)
This commit is contained in:
parent
14c65180df
commit
e1fcb02867
|
@ -28,14 +28,17 @@ class Admin::Metrics::Measure::TagServersMeasure < Admin::Metrics::Measure::Base
|
||||||
def sql_query_string
|
def sql_query_string
|
||||||
<<~SQL.squish
|
<<~SQL.squish
|
||||||
SELECT axis.*, (
|
SELECT axis.*, (
|
||||||
SELECT count(distinct accounts.domain) AS value
|
WITH tag_servers AS (
|
||||||
FROM statuses
|
SELECT DISTINCT accounts.domain
|
||||||
INNER JOIN statuses_tags ON statuses.id = statuses_tags.status_id
|
FROM statuses
|
||||||
INNER JOIN accounts ON statuses.account_id = accounts.id
|
INNER JOIN statuses_tags ON statuses.id = statuses_tags.status_id
|
||||||
WHERE statuses_tags.tag_id = :tag_id
|
INNER JOIN accounts ON statuses.account_id = accounts.id
|
||||||
AND statuses.id BETWEEN :earliest_status_id AND :latest_status_id
|
WHERE statuses_tags.tag_id = :tag_id
|
||||||
AND date_trunc('day', statuses.created_at)::date = axis.period
|
AND statuses.id BETWEEN :earliest_status_id AND :latest_status_id
|
||||||
)
|
AND date_trunc('day', statuses.created_at)::date = axis.period
|
||||||
|
)
|
||||||
|
SELECT COUNT(*) FROM tag_servers
|
||||||
|
) AS value
|
||||||
FROM (
|
FROM (
|
||||||
SELECT generate_series(date_trunc('day', :start_at::timestamp)::date, date_trunc('day', :end_at::timestamp)::date, interval '1 day') AS period
|
SELECT generate_series(date_trunc('day', :start_at::timestamp)::date, date_trunc('day', :end_at::timestamp)::date, interval '1 day') AS period
|
||||||
) as axis
|
) as axis
|
||||||
|
|
Loading…
Reference in a new issue