mirror of
https://github.com/mastodon/mastodon.git
synced 2024-08-20 21:08:15 -07:00
Use AR to build
This commit is contained in:
parent
13888d827c
commit
c570eca393
2 changed files with 25 additions and 16 deletions
|
@ -41,13 +41,15 @@ class Admin::Metrics::Measure::InstanceMediaAttachmentsMeasure < Admin::Metrics:
|
||||||
end
|
end
|
||||||
|
|
||||||
def data_source_query
|
def data_source_query
|
||||||
<<~SQL.squish
|
MediaAttachment
|
||||||
SELECT COALESCE(media_attachments.file_file_size, 0) + COALESCE(media_attachments.thumbnail_file_size, 0) AS size
|
.select('COALESCE(media_attachments.file_file_size, 0) + COALESCE(media_attachments.thumbnail_file_size, 0) AS size')
|
||||||
FROM media_attachments
|
.joins(:account)
|
||||||
INNER JOIN accounts ON accounts.id = media_attachments.account_id
|
.where(account_domain_sql(params[:include_subdomains]))
|
||||||
WHERE date_trunc('day', media_attachments.created_at)::date = axis.period
|
.where(
|
||||||
AND #{account_domain_sql(params[:include_subdomains])}
|
<<~SQL.squish
|
||||||
SQL
|
DATE_TRUNC('day', media_attachments.created_at)::date = axis.period
|
||||||
|
SQL
|
||||||
|
).to_sql
|
||||||
end
|
end
|
||||||
|
|
||||||
def select_target
|
def select_target
|
||||||
|
|
|
@ -26,15 +26,22 @@ class Admin::Metrics::Measure::TagServersMeasure < Admin::Metrics::Measure::Base
|
||||||
end
|
end
|
||||||
|
|
||||||
def data_source_query
|
def data_source_query
|
||||||
<<~SQL.squish
|
Status
|
||||||
SELECT DISTINCT accounts.domain
|
.select('accounts.domain')
|
||||||
FROM statuses
|
.distinct
|
||||||
INNER JOIN statuses_tags ON statuses.id = statuses_tags.status_id
|
.reorder(nil)
|
||||||
INNER JOIN accounts ON statuses.account_id = accounts.id
|
.joins(:tags, :account)
|
||||||
WHERE statuses_tags.tag_id = :tag_id
|
.where(
|
||||||
AND statuses.id BETWEEN :earliest_status_id AND :latest_status_id
|
<<~SQL.squish
|
||||||
AND date_trunc('day', statuses.created_at)::date = axis.period
|
statuses_tags.tag_id = :tag_id
|
||||||
SQL
|
AND statuses.id BETWEEN :earliest_status_id AND :latest_status_id
|
||||||
|
SQL
|
||||||
|
)
|
||||||
|
.where(
|
||||||
|
<<~SQL.squish
|
||||||
|
date_trunc('day', statuses.created_at)::date = axis.period
|
||||||
|
SQL
|
||||||
|
).to_sql
|
||||||
end
|
end
|
||||||
|
|
||||||
def earliest_status_id
|
def earliest_status_id
|
||||||
|
|
Loading…
Reference in a new issue