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 def data_source_query
Account Account
.select(:id) .select(:id)
.where(account_domain_sql(params[:include_subdomains]))
.where( .where(
<<~SQL.squish <<~SQL.squish
DATE_TRUNC('day', accounts.created_at)::date = axis.period DATE_TRUNC('day', accounts.created_at)::date = axis.period
AND #{account_domain_sql(params[:include_subdomains])}
SQL SQL
).to_sql ).to_sql
end end

View file

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

View file

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

View file

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

View file

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