gearheads
/
mastodon
Archived
2
0
Fork 0

Update `Admin::Metrics::Measure` classes for Rails 7 (#25236)

gh/dev
Matt Jankowski 2023-06-05 14:46:04 -04:00 committed by GitHub
parent e428670e61
commit af135bddd0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
25 changed files with 307 additions and 117 deletions

View File

@ -1,6 +1,8 @@
# frozen_string_literal: true # frozen_string_literal: true
class Admin::Metrics::Measure::InstanceAccountsMeasure < Admin::Metrics::Measure::BaseMeasure class Admin::Metrics::Measure::InstanceAccountsMeasure < Admin::Metrics::Measure::BaseMeasure
include Admin::Metrics::Measure::QueryHelper
def self.with_params? def self.with_params?
true true
end end
@ -25,33 +27,25 @@ class Admin::Metrics::Measure::InstanceAccountsMeasure < Admin::Metrics::Measure
nil nil
end end
def perform_data_query def sql_array
account_matching_sql = begin [sql_query_string, { start_at: @start_at, end_at: @end_at, domain: params[:domain] }]
if params[:include_subdomains] end
"accounts.domain IN (SELECT domain FROM instances WHERE reverse('.' || domain) LIKE reverse('.' || $3::text))"
else
'accounts.domain = $3::text'
end
end
sql = <<-SQL.squish def sql_query_string
<<~SQL.squish
SELECT axis.*, ( SELECT axis.*, (
WITH new_accounts AS ( WITH new_accounts AS (
SELECT accounts.id SELECT accounts.id
FROM accounts FROM accounts
WHERE date_trunc('day', accounts.created_at)::date = axis.period WHERE date_trunc('day', accounts.created_at)::date = axis.period
AND #{account_matching_sql} AND #{account_domain_sql(params[:include_subdomains])}
) )
SELECT count(*) FROM new_accounts SELECT count(*) FROM new_accounts
) AS value ) AS value
FROM ( FROM (
SELECT generate_series(date_trunc('day', $1::timestamp)::date, date_trunc('day', $2::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
) AS axis ) AS axis
SQL SQL
rows = ActiveRecord::Base.connection.select_all(sql, nil, [[nil, @start_at], [nil, @end_at], [nil, params[:domain]]])
rows.map { |row| { date: row['period'], value: row['value'].to_s } }
end end
def time_period def time_period

View File

@ -1,6 +1,8 @@
# frozen_string_literal: true # frozen_string_literal: true
class Admin::Metrics::Measure::InstanceFollowersMeasure < Admin::Metrics::Measure::BaseMeasure class Admin::Metrics::Measure::InstanceFollowersMeasure < Admin::Metrics::Measure::BaseMeasure
include Admin::Metrics::Measure::QueryHelper
def self.with_params? def self.with_params?
true true
end end
@ -25,34 +27,26 @@ class Admin::Metrics::Measure::InstanceFollowersMeasure < Admin::Metrics::Measur
nil nil
end end
def perform_data_query def sql_array
account_matching_sql = begin [sql_query_string, { start_at: @start_at, end_at: @end_at, domain: params[:domain] }]
if params[:include_subdomains] end
"accounts.domain IN (SELECT domain FROM instances WHERE reverse('.' || domain) LIKE reverse('.' || $3::text))"
else
'accounts.domain = $3::text'
end
end
sql = <<-SQL.squish def sql_query_string
<<~SQL.squish
SELECT axis.*, ( SELECT axis.*, (
WITH new_followers AS ( WITH new_followers AS (
SELECT follows.id SELECT follows.id
FROM follows FROM follows
INNER JOIN accounts ON follows.account_id = accounts.id INNER JOIN accounts ON follows.account_id = accounts.id
WHERE date_trunc('day', follows.created_at)::date = axis.period WHERE date_trunc('day', follows.created_at)::date = axis.period
AND #{account_matching_sql} AND #{account_domain_sql(params[:include_subdomains])}
) )
SELECT count(*) FROM new_followers SELECT count(*) FROM new_followers
) AS value ) AS value
FROM ( FROM (
SELECT generate_series(date_trunc('day', $1::timestamp)::date, date_trunc('day', $2::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
) AS axis ) AS axis
SQL SQL
rows = ActiveRecord::Base.connection.select_all(sql, nil, [[nil, @start_at], [nil, @end_at], [nil, params[:domain]]])
rows.map { |row| { date: row['period'], value: row['value'].to_s } }
end end
def time_period def time_period

View File

@ -1,6 +1,8 @@
# frozen_string_literal: true # frozen_string_literal: true
class Admin::Metrics::Measure::InstanceFollowsMeasure < Admin::Metrics::Measure::BaseMeasure class Admin::Metrics::Measure::InstanceFollowsMeasure < Admin::Metrics::Measure::BaseMeasure
include Admin::Metrics::Measure::QueryHelper
def self.with_params? def self.with_params?
true true
end end
@ -25,34 +27,26 @@ class Admin::Metrics::Measure::InstanceFollowsMeasure < Admin::Metrics::Measure:
nil nil
end end
def perform_data_query def sql_array
account_matching_sql = begin [sql_query_string, { start_at: @start_at, end_at: @end_at, domain: params[:domain] }]
if params[:include_subdomains] end
"accounts.domain IN (SELECT domain FROM instances WHERE reverse('.' || domain) LIKE reverse('.' || $3::text))"
else
'accounts.domain = $3::text'
end
end
sql = <<-SQL.squish def sql_query_string
<<~SQL.squish
SELECT axis.*, ( SELECT axis.*, (
WITH new_follows AS ( WITH new_follows AS (
SELECT follows.id SELECT follows.id
FROM follows FROM follows
INNER JOIN accounts ON follows.target_account_id = accounts.id INNER JOIN accounts ON follows.target_account_id = accounts.id
WHERE date_trunc('day', follows.created_at)::date = axis.period WHERE date_trunc('day', follows.created_at)::date = axis.period
AND #{account_matching_sql} AND #{account_domain_sql(params[:include_subdomains])}
) )
SELECT count(*) FROM new_follows SELECT count(*) FROM new_follows
) AS value ) AS value
FROM ( FROM (
SELECT generate_series(date_trunc('day', $1::timestamp)::date, date_trunc('day', $2::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
) AS axis ) AS axis
SQL SQL
rows = ActiveRecord::Base.connection.select_all(sql, nil, [[nil, @start_at], [nil, @end_at], [nil, params[:domain]]])
rows.map { |row| { date: row['period'], value: row['value'].to_s } }
end end
def time_period def time_period

View File

@ -1,6 +1,7 @@
# frozen_string_literal: true # frozen_string_literal: true
class Admin::Metrics::Measure::InstanceMediaAttachmentsMeasure < Admin::Metrics::Measure::BaseMeasure class Admin::Metrics::Measure::InstanceMediaAttachmentsMeasure < Admin::Metrics::Measure::BaseMeasure
include Admin::Metrics::Measure::QueryHelper
include ActionView::Helpers::NumberHelper include ActionView::Helpers::NumberHelper
def self.with_params? def self.with_params?
@ -35,34 +36,26 @@ class Admin::Metrics::Measure::InstanceMediaAttachmentsMeasure < Admin::Metrics:
nil nil
end end
def perform_data_query def sql_array
account_matching_sql = begin [sql_query_string, { start_at: @start_at, end_at: @end_at, domain: params[:domain] }]
if params[:include_subdomains] end
"accounts.domain IN (SELECT domain FROM instances WHERE reverse('.' || domain) LIKE reverse('.' || $3::text))"
else
'accounts.domain = $3::text'
end
end
sql = <<-SQL.squish def sql_query_string
<<~SQL.squish
SELECT axis.*, ( SELECT axis.*, (
WITH new_media_attachments AS ( WITH new_media_attachments AS (
SELECT COALESCE(media_attachments.file_file_size, 0) + COALESCE(media_attachments.thumbnail_file_size, 0) AS size SELECT COALESCE(media_attachments.file_file_size, 0) + COALESCE(media_attachments.thumbnail_file_size, 0) AS size
FROM media_attachments FROM media_attachments
INNER JOIN accounts ON accounts.id = media_attachments.account_id INNER JOIN accounts ON accounts.id = media_attachments.account_id
WHERE date_trunc('day', media_attachments.created_at)::date = axis.period WHERE date_trunc('day', media_attachments.created_at)::date = axis.period
AND #{account_matching_sql} AND #{account_domain_sql(params[:include_subdomains])}
) )
SELECT SUM(size) FROM new_media_attachments SELECT SUM(size) FROM new_media_attachments
) AS value ) AS value
FROM ( FROM (
SELECT generate_series(date_trunc('day', $1::timestamp)::date, date_trunc('day', $2::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
) AS axis ) AS axis
SQL SQL
rows = ActiveRecord::Base.connection.select_all(sql, nil, [[nil, @start_at], [nil, @end_at], [nil, params[:domain]]])
rows.map { |row| { date: row['period'], value: row['value'].to_s } }
end end
def time_period def time_period

View File

@ -1,6 +1,8 @@
# frozen_string_literal: true # frozen_string_literal: true
class Admin::Metrics::Measure::InstanceReportsMeasure < Admin::Metrics::Measure::BaseMeasure class Admin::Metrics::Measure::InstanceReportsMeasure < Admin::Metrics::Measure::BaseMeasure
include Admin::Metrics::Measure::QueryHelper
def self.with_params? def self.with_params?
true true
end end
@ -25,34 +27,26 @@ class Admin::Metrics::Measure::InstanceReportsMeasure < Admin::Metrics::Measure:
nil nil
end end
def perform_data_query def sql_array
account_matching_sql = begin [sql_query_string, { start_at: @start_at, end_at: @end_at, domain: params[:domain] }]
if params[:include_subdomains] end
"accounts.domain IN (SELECT domain FROM instances WHERE reverse('.' || domain) LIKE reverse('.' || $3::text))"
else
'accounts.domain = $3::text'
end
end
sql = <<-SQL.squish def sql_query_string
<<~SQL.squish
SELECT axis.*, ( SELECT axis.*, (
WITH new_reports AS ( WITH new_reports AS (
SELECT reports.id SELECT reports.id
FROM reports FROM reports
INNER JOIN accounts ON accounts.id = reports.target_account_id INNER JOIN accounts ON accounts.id = reports.target_account_id
WHERE date_trunc('day', reports.created_at)::date = axis.period WHERE date_trunc('day', reports.created_at)::date = axis.period
AND #{account_matching_sql} AND #{account_domain_sql(params[:include_subdomains])}
) )
SELECT count(*) FROM new_reports SELECT count(*) FROM new_reports
) AS value ) AS value
FROM ( FROM (
SELECT generate_series(date_trunc('day', $1::timestamp)::date, date_trunc('day', $2::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
) AS axis ) AS axis
SQL SQL
rows = ActiveRecord::Base.connection.select_all(sql, nil, [[nil, @start_at], [nil, @end_at], [nil, params[:domain]]])
rows.map { |row| { date: row['period'], value: row['value'].to_s } }
end end
def time_period def time_period

View File

@ -1,6 +1,8 @@
# frozen_string_literal: true # frozen_string_literal: true
class Admin::Metrics::Measure::InstanceStatusesMeasure < Admin::Metrics::Measure::BaseMeasure class Admin::Metrics::Measure::InstanceStatusesMeasure < Admin::Metrics::Measure::BaseMeasure
include Admin::Metrics::Measure::QueryHelper
def self.with_params? def self.with_params?
true true
end end
@ -25,35 +27,35 @@ class Admin::Metrics::Measure::InstanceStatusesMeasure < Admin::Metrics::Measure
nil nil
end end
def perform_data_query def sql_array
account_matching_sql = begin [sql_query_string, { start_at: @start_at, end_at: @end_at, domain: params[:domain], earliest_status_id: earliest_status_id, latest_status_id: latest_status_id }]
if params[:include_subdomains] end
"accounts.domain IN (SELECT domain FROM instances WHERE reverse('.' || domain) LIKE reverse('.' || $5::text))"
else
'accounts.domain = $5::text'
end
end
sql = <<-SQL.squish def sql_query_string
<<~SQL.squish
SELECT axis.*, ( SELECT axis.*, (
WITH new_statuses AS ( WITH new_statuses AS (
SELECT statuses.id SELECT statuses.id
FROM statuses FROM statuses
INNER JOIN accounts ON accounts.id = statuses.account_id INNER JOIN accounts ON accounts.id = statuses.account_id
WHERE statuses.id BETWEEN $3 AND $4 WHERE statuses.id BETWEEN :earliest_status_id AND :latest_status_id
AND #{account_matching_sql} AND #{account_domain_sql(params[:include_subdomains])}
AND date_trunc('day', statuses.created_at)::date = axis.period AND date_trunc('day', statuses.created_at)::date = axis.period
) )
SELECT count(*) FROM new_statuses SELECT count(*) FROM new_statuses
) AS value ) AS value
FROM ( FROM (
SELECT generate_series(date_trunc('day', $1::timestamp)::date, date_trunc('day', $2::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
) AS axis ) AS axis
SQL SQL
end
rows = ActiveRecord::Base.connection.select_all(sql, nil, [[nil, @start_at], [nil, @end_at], [nil, Mastodon::Snowflake.id_at(@start_at, with_random: false)], [nil, Mastodon::Snowflake.id_at(@end_at, with_random: false)], [nil, params[:domain]]]) def earliest_status_id
Mastodon::Snowflake.id_at(@start_at, with_random: false)
end
rows.map { |row| { date: row['period'], value: row['value'].to_s } } def latest_status_id
Mastodon::Snowflake.id_at(@end_at, with_random: false)
end end
def time_period def time_period

View File

@ -1,6 +1,8 @@
# frozen_string_literal: true # frozen_string_literal: true
class Admin::Metrics::Measure::NewUsersMeasure < Admin::Metrics::Measure::BaseMeasure class Admin::Metrics::Measure::NewUsersMeasure < Admin::Metrics::Measure::BaseMeasure
include Admin::Metrics::Measure::QueryHelper
def key def key
'new_users' 'new_users'
end end
@ -15,8 +17,12 @@ class Admin::Metrics::Measure::NewUsersMeasure < Admin::Metrics::Measure::BaseMe
User.where(created_at: previous_time_period).count User.where(created_at: previous_time_period).count
end end
def perform_data_query def sql_array
sql = <<-SQL.squish [sql_query_string, { start_at: @start_at, end_at: @end_at }]
end
def sql_query_string
<<~SQL.squish
SELECT axis.*, ( SELECT axis.*, (
WITH new_users AS ( WITH new_users AS (
SELECT users.id SELECT users.id
@ -26,12 +32,8 @@ class Admin::Metrics::Measure::NewUsersMeasure < Admin::Metrics::Measure::BaseMe
SELECT count(*) FROM new_users SELECT count(*) FROM new_users
) AS value ) AS value
FROM ( FROM (
SELECT generate_series(date_trunc('day', $1::timestamp)::date, date_trunc('day', $2::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
) AS axis ) AS axis
SQL SQL
rows = ActiveRecord::Base.connection.select_all(sql, nil, [[nil, @start_at], [nil, @end_at]])
rows.map { |row| { date: row['period'], value: row['value'].to_s } }
end end
end end

View File

@ -1,6 +1,8 @@
# frozen_string_literal: true # frozen_string_literal: true
class Admin::Metrics::Measure::OpenedReportsMeasure < Admin::Metrics::Measure::BaseMeasure class Admin::Metrics::Measure::OpenedReportsMeasure < Admin::Metrics::Measure::BaseMeasure
include Admin::Metrics::Measure::QueryHelper
def key def key
'opened_reports' 'opened_reports'
end end
@ -15,8 +17,12 @@ class Admin::Metrics::Measure::OpenedReportsMeasure < Admin::Metrics::Measure::B
Report.where(created_at: previous_time_period).count Report.where(created_at: previous_time_period).count
end end
def perform_data_query def sql_array
sql = <<-SQL.squish [sql_query_string, { start_at: @start_at, end_at: @end_at }]
end
def sql_query_string
<<~SQL.squish
SELECT axis.*, ( SELECT axis.*, (
WITH new_reports AS ( WITH new_reports AS (
SELECT reports.id SELECT reports.id
@ -26,12 +32,8 @@ class Admin::Metrics::Measure::OpenedReportsMeasure < Admin::Metrics::Measure::B
SELECT count(*) FROM new_reports SELECT count(*) FROM new_reports
) AS value ) AS value
FROM ( FROM (
SELECT generate_series(date_trunc('day', $1::timestamp)::date, date_trunc('day', $2::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
) AS axis ) AS axis
SQL SQL
rows = ActiveRecord::Base.connection.select_all(sql, nil, [[nil, @start_at], [nil, @end_at]])
rows.map { |row| { date: row['period'], value: row['value'].to_s } }
end end
end end

View 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

View File

@ -1,6 +1,8 @@
# frozen_string_literal: true # frozen_string_literal: true
class Admin::Metrics::Measure::ResolvedReportsMeasure < Admin::Metrics::Measure::BaseMeasure class Admin::Metrics::Measure::ResolvedReportsMeasure < Admin::Metrics::Measure::BaseMeasure
include Admin::Metrics::Measure::QueryHelper
def key def key
'resolved_reports' 'resolved_reports'
end end
@ -15,8 +17,12 @@ class Admin::Metrics::Measure::ResolvedReportsMeasure < Admin::Metrics::Measure:
Report.resolved.where(action_taken_at: previous_time_period).count Report.resolved.where(action_taken_at: previous_time_period).count
end end
def perform_data_query def sql_array
sql = <<-SQL.squish [sql_query_string, { start_at: @start_at, end_at: @end_at }]
end
def sql_query_string
<<~SQL.squish
SELECT axis.*, ( SELECT axis.*, (
WITH resolved_reports AS ( WITH resolved_reports AS (
SELECT reports.id SELECT reports.id
@ -26,12 +32,8 @@ class Admin::Metrics::Measure::ResolvedReportsMeasure < Admin::Metrics::Measure:
SELECT count(*) FROM resolved_reports SELECT count(*) FROM resolved_reports
) AS value ) AS value
FROM ( FROM (
SELECT generate_series(date_trunc('day', $1::timestamp)::date, date_trunc('day', $2::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
) AS axis ) AS axis
SQL SQL
rows = ActiveRecord::Base.connection.select_all(sql, nil, [[nil, @start_at], [nil, @end_at]])
rows.map { |row| { date: row['period'], value: row['value'].to_s } }
end end
end end

View File

@ -1,6 +1,8 @@
# frozen_string_literal: true # frozen_string_literal: true
class Admin::Metrics::Measure::TagServersMeasure < Admin::Metrics::Measure::BaseMeasure class Admin::Metrics::Measure::TagServersMeasure < Admin::Metrics::Measure::BaseMeasure
include Admin::Metrics::Measure::QueryHelper
def self.with_params? def self.with_params?
true true
end end
@ -19,25 +21,33 @@ class Admin::Metrics::Measure::TagServersMeasure < Admin::Metrics::Measure::Base
tag.statuses.where('statuses.id BETWEEN ? AND ?', Mastodon::Snowflake.id_at(@start_at - length_of_period, with_random: false), Mastodon::Snowflake.id_at(@end_at - length_of_period, with_random: false)).joins(:account).count('distinct accounts.domain') tag.statuses.where('statuses.id BETWEEN ? AND ?', Mastodon::Snowflake.id_at(@start_at - length_of_period, with_random: false), Mastodon::Snowflake.id_at(@end_at - length_of_period, with_random: false)).joins(:account).count('distinct accounts.domain')
end end
def perform_data_query def sql_array
sql = <<-SQL.squish [sql_query_string, { start_at: @start_at, end_at: @end_at, tag_id: tag.id, earliest_status_id: earliest_status_id, latest_status_id: latest_status_id }]
end
def sql_query_string
<<~SQL.squish
SELECT axis.*, ( SELECT axis.*, (
SELECT count(distinct accounts.domain) AS value SELECT count(distinct accounts.domain) AS value
FROM statuses FROM statuses
INNER JOIN statuses_tags ON statuses.id = statuses_tags.status_id INNER JOIN statuses_tags ON statuses.id = statuses_tags.status_id
INNER JOIN accounts ON statuses.account_id = accounts.id INNER JOIN accounts ON statuses.account_id = accounts.id
WHERE statuses_tags.tag_id = $1 WHERE statuses_tags.tag_id = :tag_id
AND statuses.id BETWEEN $2 AND $3 AND statuses.id BETWEEN :earliest_status_id AND :latest_status_id
AND date_trunc('day', statuses.created_at)::date = axis.day AND date_trunc('day', statuses.created_at)::date = axis.day
) )
FROM ( FROM (
SELECT generate_series(date_trunc('day', $4::timestamp)::date, date_trunc('day', $5::timestamp)::date, ('1 day')::interval) AS day SELECT generate_series(date_trunc('day', :start_at::timestamp)::date, date_trunc('day', :end_at::timestamp)::date, ('1 day')::interval) AS day
) as axis ) as axis
SQL SQL
end
rows = ActiveRecord::Base.connection.select_all(sql, nil, [[nil, params[:id].to_i], [nil, Mastodon::Snowflake.id_at(@start_at, with_random: false)], [nil, Mastodon::Snowflake.id_at(@end_at, with_random: false)], [nil, @start_at], [nil, @end_at]]) def earliest_status_id
Mastodon::Snowflake.id_at(@start_at, with_random: false)
end
rows.map { |row| { date: row['day'], value: row['value'].to_s } } def latest_status_id
Mastodon::Snowflake.id_at(@end_at, with_random: false)
end end
def tag def tag

View File

@ -0,0 +1,17 @@
# frozen_string_literal: true
require 'rails_helper'
describe Admin::Metrics::Measure::ActiveUsersMeasure do
subject(:measure) { described_class.new(start_at, end_at, params) }
let(:start_at) { 2.days.ago }
let(:end_at) { Time.now.utc }
let(:params) { ActionController::Parameters.new }
describe '#data' do
it 'runs data query without error' do
expect { measure.data }.to_not raise_error
end
end
end

View File

@ -37,4 +37,10 @@ describe Admin::Metrics::Measure::InstanceAccountsMeasure do
end end
end end
end end
describe '#data' do
it 'runs data query without error' do
expect { measure.data }.to_not raise_error
end
end
end end

View File

@ -39,4 +39,10 @@ describe Admin::Metrics::Measure::InstanceFollowersMeasure do
end end
end end
end end
describe '#data' do
it 'runs data query without error' do
expect { measure.data }.to_not raise_error
end
end
end end

View File

@ -39,4 +39,10 @@ describe Admin::Metrics::Measure::InstanceFollowsMeasure do
end end
end end
end end
describe '#data' do
it 'runs data query without error' do
expect { measure.data }.to_not raise_error
end
end
end end

View File

@ -40,4 +40,10 @@ describe Admin::Metrics::Measure::InstanceMediaAttachmentsMeasure do
end end
end end
end end
describe '#data' do
it 'runs data query without error' do
expect { measure.data }.to_not raise_error
end
end
end end

View File

@ -36,4 +36,10 @@ describe Admin::Metrics::Measure::InstanceReportsMeasure do
end end
end end
end end
describe '#data' do
it 'runs data query without error' do
expect { measure.data }.to_not raise_error
end
end
end end

View File

@ -36,4 +36,10 @@ describe Admin::Metrics::Measure::InstanceStatusesMeasure do
end end
end end
end end
describe '#data' do
it 'runs data query without error' do
expect { measure.data }.to_not raise_error
end
end
end end

View File

@ -0,0 +1,17 @@
# frozen_string_literal: true
require 'rails_helper'
describe Admin::Metrics::Measure::InteractionsMeasure do
subject(:measure) { described_class.new(start_at, end_at, params) }
let(:start_at) { 2.days.ago }
let(:end_at) { Time.now.utc }
let(:params) { ActionController::Parameters.new }
describe '#data' do
it 'runs data query without error' do
expect { measure.data }.to_not raise_error
end
end
end

View File

@ -0,0 +1,17 @@
# frozen_string_literal: true
require 'rails_helper'
describe Admin::Metrics::Measure::NewUsersMeasure do
subject(:measure) { described_class.new(start_at, end_at, params) }
let(:start_at) { 2.days.ago }
let(:end_at) { Time.now.utc }
let(:params) { ActionController::Parameters.new }
describe '#data' do
it 'runs data query without error' do
expect { measure.data }.to_not raise_error
end
end
end

View File

@ -0,0 +1,17 @@
# frozen_string_literal: true
require 'rails_helper'
describe Admin::Metrics::Measure::OpenedReportsMeasure do
subject(:measure) { described_class.new(start_at, end_at, params) }
let(:start_at) { 2.days.ago }
let(:end_at) { Time.now.utc }
let(:params) { ActionController::Parameters.new }
describe '#data' do
it 'runs data query without error' do
expect { measure.data }.to_not raise_error
end
end
end

View File

@ -0,0 +1,17 @@
# frozen_string_literal: true
require 'rails_helper'
describe Admin::Metrics::Measure::ResolvedReportsMeasure do
subject(:measure) { described_class.new(start_at, end_at, params) }
let(:start_at) { 2.days.ago }
let(:end_at) { Time.now.utc }
let(:params) { ActionController::Parameters.new }
describe '#data' do
it 'runs data query without error' do
expect { measure.data }.to_not raise_error
end
end
end

View File

@ -0,0 +1,19 @@
# frozen_string_literal: true
require 'rails_helper'
describe Admin::Metrics::Measure::TagAccountsMeasure do
subject(:measure) { described_class.new(start_at, end_at, params) }
let!(:tag) { Fabricate(:tag) }
let(:start_at) { 2.days.ago }
let(:end_at) { Time.now.utc }
let(:params) { ActionController::Parameters.new(id: tag.id) }
describe '#data' do
it 'runs data query without error' do
expect { measure.data }.to_not raise_error
end
end
end

View File

@ -0,0 +1,19 @@
# frozen_string_literal: true
require 'rails_helper'
describe Admin::Metrics::Measure::TagServersMeasure do
subject(:measure) { described_class.new(start_at, end_at, params) }
let!(:tag) { Fabricate(:tag) }
let(:start_at) { 2.days.ago }
let(:end_at) { Time.now.utc }
let(:params) { ActionController::Parameters.new(id: tag.id) }
describe '#data' do
it 'runs data query without error' do
expect { measure.data }.to_not raise_error
end
end
end

View File

@ -0,0 +1,19 @@
# frozen_string_literal: true
require 'rails_helper'
describe Admin::Metrics::Measure::TagUsesMeasure do
subject(:measure) { described_class.new(start_at, end_at, params) }
let!(:tag) { Fabricate(:tag) }
let(:start_at) { 2.days.ago }
let(:end_at) { Time.now.utc }
let(:params) { ActionController::Parameters.new(id: tag.id) }
describe '#data' do
it 'runs data query without error' do
expect { measure.data }.to_not raise_error
end
end
end