From 84411d4c974cc0901fb7d901b3ed2122fe182cd4 Mon Sep 17 00:00:00 2001 From: Matt Jankowski Date: Tue, 11 Jun 2024 11:44:11 -0400 Subject: [PATCH] Embroil it in controversery --- app/lib/admin/metrics/measure/instance_statuses_measure.rb | 6 +----- app/lib/admin/metrics/measure/query_helper.rb | 6 ++++++ app/lib/admin/metrics/measure/tag_servers_measure.rb | 6 +----- 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/app/lib/admin/metrics/measure/instance_statuses_measure.rb b/app/lib/admin/metrics/measure/instance_statuses_measure.rb index b574b19c4d4..bac11fc384a 100644 --- a/app/lib/admin/metrics/measure/instance_statuses_measure.rb +++ b/app/lib/admin/metrics/measure/instance_statuses_measure.rb @@ -32,11 +32,7 @@ class Admin::Metrics::Measure::InstanceStatusesMeasure < Admin::Metrics::Measure .select(:id) .joins(:account) .where(account_domain_sql, domain: params[:domain]) - .where( - <<~SQL.squish, earliest_status_id: earliest_status_id, latest_status_id: latest_status_id - statuses.id BETWEEN :earliest_status_id AND :latest_status_id - SQL - ) + .where(status_range_sql, earliest_status_id: earliest_status_id, latest_status_id: latest_status_id) .where(daily_period(:statuses)) end diff --git a/app/lib/admin/metrics/measure/query_helper.rb b/app/lib/admin/metrics/measure/query_helper.rb index 7c019ed2638..e6142c97f25 100644 --- a/app/lib/admin/metrics/measure/query_helper.rb +++ b/app/lib/admin/metrics/measure/query_helper.rb @@ -43,6 +43,12 @@ module Admin::Metrics::Measure::QueryHelper SQL end + def status_range_sql + <<~SQL.squish + statuses.id BETWEEN :earliest_status_id AND :latest_status_id + SQL + end + def account_domain_sql if params[:include_subdomains] <<~SQL.squish diff --git a/app/lib/admin/metrics/measure/tag_servers_measure.rb b/app/lib/admin/metrics/measure/tag_servers_measure.rb index 089d1cba3b2..bb35acc3593 100644 --- a/app/lib/admin/metrics/measure/tag_servers_measure.rb +++ b/app/lib/admin/metrics/measure/tag_servers_measure.rb @@ -28,11 +28,7 @@ class Admin::Metrics::Measure::TagServersMeasure < Admin::Metrics::Measure::Base .reorder(nil) .joins(:tags, :account) .where(statuses_tags: { tag_id: tag.id }) - .where( - <<~SQL.squish, earliest_status_id: earliest_status_id, latest_status_id: latest_status_id - statuses.id BETWEEN :earliest_status_id AND :latest_status_id - SQL - ) + .where(status_range_sql, earliest_status_id: earliest_status_id, latest_status_id: latest_status_id) .where(daily_period(:statuses)) end