1
0
Fork 0
mirror of https://github.com/mastodon/mastodon.git synced 2024-08-20 21:08:15 -07:00

Isolate date trunc

This commit is contained in:
Matt Jankowski 2024-06-11 09:56:55 -04:00
parent e2a243ae31
commit 13888d827c
5 changed files with 10 additions and 6 deletions

View file

@ -34,10 +34,10 @@ class Admin::Metrics::Measure::InstanceAccountsMeasure < Admin::Metrics::Measure
def data_source_query
Account
.select(:id)
.where(account_domain_sql(params[:include_subdomains]))
.where(
<<~SQL.squish
DATE_TRUNC('day', accounts.created_at)::date = axis.period
AND #{account_domain_sql(params[:include_subdomains])}
SQL
).to_sql
end

View file

@ -35,10 +35,10 @@ class Admin::Metrics::Measure::InstanceFollowersMeasure < Admin::Metrics::Measur
Follow
.select(:id)
.joins(:account)
.where(account_domain_sql(params[:include_subdomains]))
.where(
<<~SQL.squish
DATE_TRUNC('day', follows.created_at)::date = axis.period
AND #{account_domain_sql(params[:include_subdomains])}
SQL
).to_sql
end

View file

@ -35,10 +35,10 @@ class Admin::Metrics::Measure::InstanceFollowsMeasure < Admin::Metrics::Measure:
Follow
.select(:id)
.joins(:target_account)
.where(account_domain_sql(params[:include_subdomains]))
.where(
<<~SQL.squish
DATE_TRUNC('day', follows.created_at)::date = axis.period
AND #{account_domain_sql(params[:include_subdomains])}
SQL
).to_sql
end

View file

@ -35,10 +35,10 @@ class Admin::Metrics::Measure::InstanceReportsMeasure < Admin::Metrics::Measure:
Report
.select(:id)
.joins(:target_account)
.where(account_domain_sql(params[:include_subdomains]))
.where(
<<~SQL.squish
DATE_TRUNC('day', reports.created_at)::date = axis.period
AND #{account_domain_sql(params[:include_subdomains])}
SQL
).to_sql
end

View file

@ -35,11 +35,15 @@ class Admin::Metrics::Measure::InstanceStatusesMeasure < Admin::Metrics::Measure
Status
.select(:id)
.joins(:account)
.where(account_domain_sql(params[:include_subdomains]))
.where(
<<~SQL.squish
statuses.id BETWEEN :earliest_status_id AND :latest_status_id
AND #{account_domain_sql(params[:include_subdomains])}
AND date_trunc('day', statuses.created_at)::date = axis.period
SQL
)
.where(
<<~SQL.squish
date_trunc('day', statuses.created_at)::date = axis.period
SQL
).to_sql
end