0
0
Fork 0

Extract method to generate series of days in measure sql classes (#29928)

This commit is contained in:
Matt Jankowski 2024-06-11 03:42:15 -04:00 committed by GitHub
parent edf6d64eeb
commit 88cfc4056d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
11 changed files with 18 additions and 10 deletions

View file

@ -15,6 +15,14 @@ module Admin::Metrics::Measure::QueryHelper
ActiveRecord::Base.sanitize_sql_array(sql_array)
end
def generated_series_days
Arel.sql(
<<~SQL.squish
SELECT generate_series(timestamp :start_at, :end_at, '1 day')::date AS period
SQL
)
end
def account_domain_sql(include_subdomains)
if include_subdomains
"accounts.domain IN (SELECT domain FROM instances WHERE reverse('.' || domain) LIKE reverse('.' || :domain::text))"