Wrap media attachment size calculation in `COALESCE` (#29415)

This commit is contained in:
Matt Jankowski 2024-02-27 06:52:37 -05:00 committed by GitHub
parent 9e78129e6e
commit 76d256138e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 1 additions and 1 deletions

View File

@ -50,7 +50,7 @@ class Admin::Metrics::Measure::InstanceMediaAttachmentsMeasure < Admin::Metrics:
WHERE date_trunc('day', media_attachments.created_at)::date = axis.period WHERE date_trunc('day', media_attachments.created_at)::date = axis.period
AND #{account_domain_sql(params[:include_subdomains])} AND #{account_domain_sql(params[:include_subdomains])}
) )
SELECT SUM(size) FROM new_media_attachments SELECT COALESCE(SUM(size), 0) FROM new_media_attachments
) AS value ) 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