Update Admin::Metrics::Measure
classes for Rails 7 (#25236)
This commit is contained in:
parent
e428670e61
commit
af135bddd0
25 changed files with 307 additions and 117 deletions
25
app/lib/admin/metrics/measure/query_helper.rb
Normal file
25
app/lib/admin/metrics/measure/query_helper.rb
Normal file
|
@ -0,0 +1,25 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module Admin::Metrics::Measure::QueryHelper
|
||||
protected
|
||||
|
||||
def perform_data_query
|
||||
measurement_data_rows.map { |row| { date: row['period'], value: row['value'].to_s } }
|
||||
end
|
||||
|
||||
def measurement_data_rows
|
||||
ActiveRecord::Base.connection.select_all(sanitized_sql_string)
|
||||
end
|
||||
|
||||
def sanitized_sql_string
|
||||
ActiveRecord::Base.sanitize_sql_array(sql_array)
|
||||
end
|
||||
|
||||
def account_domain_sql(include_subdomains)
|
||||
if include_subdomains
|
||||
"accounts.domain IN (SELECT domain FROM instances WHERE reverse('.' || domain) LIKE reverse('.' || :domain::text))"
|
||||
else
|
||||
'accounts.domain = :domain::text'
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue