From 76d256138e6029d848da7cfdf5b8682832c44033 Mon Sep 17 00:00:00 2001 From: Matt Jankowski Date: Tue, 27 Feb 2024 06:52:37 -0500 Subject: [PATCH] Wrap media attachment size calculation in `COALESCE` (#29415) --- .../admin/metrics/measure/instance_media_attachments_measure.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/lib/admin/metrics/measure/instance_media_attachments_measure.rb b/app/lib/admin/metrics/measure/instance_media_attachments_measure.rb index 2d4b5f56b..1d2dbbe41 100644 --- a/app/lib/admin/metrics/measure/instance_media_attachments_measure.rb +++ b/app/lib/admin/metrics/measure/instance_media_attachments_measure.rb @@ -50,7 +50,7 @@ class Admin::Metrics::Measure::InstanceMediaAttachmentsMeasure < Admin::Metrics: WHERE date_trunc('day', media_attachments.created_at)::date = axis.period 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 FROM ( SELECT generate_series(date_trunc('day', :start_at::timestamp)::date, date_trunc('day', :end_at::timestamp)::date, interval '1 day') AS period