mirror of
https://github.com/mastodon/mastodon.git
synced 2024-12-25 20:45:03 +01:00
Add coverage for admin/metrics base classes, simplify subclass generation (#29527)
This commit is contained in:
parent
b9722dfe2b
commit
a7284690fc
@ -2,15 +2,15 @@
|
||||
|
||||
class Admin::Metrics::Dimension
|
||||
DIMENSIONS = {
|
||||
languages: Admin::Metrics::Dimension::LanguagesDimension,
|
||||
sources: Admin::Metrics::Dimension::SourcesDimension,
|
||||
servers: Admin::Metrics::Dimension::ServersDimension,
|
||||
space_usage: Admin::Metrics::Dimension::SpaceUsageDimension,
|
||||
software_versions: Admin::Metrics::Dimension::SoftwareVersionsDimension,
|
||||
tag_servers: Admin::Metrics::Dimension::TagServersDimension,
|
||||
tag_languages: Admin::Metrics::Dimension::TagLanguagesDimension,
|
||||
instance_accounts: Admin::Metrics::Dimension::InstanceAccountsDimension,
|
||||
instance_languages: Admin::Metrics::Dimension::InstanceLanguagesDimension,
|
||||
languages: LanguagesDimension,
|
||||
sources: SourcesDimension,
|
||||
servers: ServersDimension,
|
||||
space_usage: SpaceUsageDimension,
|
||||
software_versions: SoftwareVersionsDimension,
|
||||
tag_servers: TagServersDimension,
|
||||
tag_languages: TagLanguagesDimension,
|
||||
instance_accounts: InstanceAccountsDimension,
|
||||
instance_languages: InstanceLanguagesDimension,
|
||||
}.freeze
|
||||
|
||||
def self.retrieve(dimension_keys, start_at, end_at, limit, params)
|
||||
|
@ -2,20 +2,20 @@
|
||||
|
||||
class Admin::Metrics::Measure
|
||||
MEASURES = {
|
||||
active_users: Admin::Metrics::Measure::ActiveUsersMeasure,
|
||||
new_users: Admin::Metrics::Measure::NewUsersMeasure,
|
||||
interactions: Admin::Metrics::Measure::InteractionsMeasure,
|
||||
opened_reports: Admin::Metrics::Measure::OpenedReportsMeasure,
|
||||
resolved_reports: Admin::Metrics::Measure::ResolvedReportsMeasure,
|
||||
tag_accounts: Admin::Metrics::Measure::TagAccountsMeasure,
|
||||
tag_uses: Admin::Metrics::Measure::TagUsesMeasure,
|
||||
tag_servers: Admin::Metrics::Measure::TagServersMeasure,
|
||||
instance_accounts: Admin::Metrics::Measure::InstanceAccountsMeasure,
|
||||
instance_media_attachments: Admin::Metrics::Measure::InstanceMediaAttachmentsMeasure,
|
||||
instance_reports: Admin::Metrics::Measure::InstanceReportsMeasure,
|
||||
instance_statuses: Admin::Metrics::Measure::InstanceStatusesMeasure,
|
||||
instance_follows: Admin::Metrics::Measure::InstanceFollowsMeasure,
|
||||
instance_followers: Admin::Metrics::Measure::InstanceFollowersMeasure,
|
||||
active_users: ActiveUsersMeasure,
|
||||
new_users: NewUsersMeasure,
|
||||
interactions: InteractionsMeasure,
|
||||
opened_reports: OpenedReportsMeasure,
|
||||
resolved_reports: ResolvedReportsMeasure,
|
||||
tag_accounts: TagAccountsMeasure,
|
||||
tag_uses: TagUsesMeasure,
|
||||
tag_servers: TagServersMeasure,
|
||||
instance_accounts: InstanceAccountsMeasure,
|
||||
instance_media_attachments: InstanceMediaAttachmentsMeasure,
|
||||
instance_reports: InstanceReportsMeasure,
|
||||
instance_statuses: InstanceStatusesMeasure,
|
||||
instance_follows: InstanceFollowsMeasure,
|
||||
instance_followers: InstanceFollowersMeasure,
|
||||
}.freeze
|
||||
|
||||
def self.retrieve(measure_keys, start_at, end_at, params)
|
||||
|
22
spec/lib/admin/metrics/dimension_spec.rb
Normal file
22
spec/lib/admin/metrics/dimension_spec.rb
Normal file
@ -0,0 +1,22 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
describe Admin::Metrics::Dimension do
|
||||
describe '.retrieve' do
|
||||
subject { described_class.retrieve(reports, start_at, end_at, 5, params) }
|
||||
|
||||
let(:start_at) { 2.days.ago }
|
||||
let(:end_at) { Time.now.utc }
|
||||
let(:params) { ActionController::Parameters.new({ instance_accounts: [123], instance_languages: ['en'] }) }
|
||||
let(:reports) { [:instance_accounts, :instance_languages] }
|
||||
|
||||
it 'returns instances of provided classes' do
|
||||
expect(subject)
|
||||
.to contain_exactly(
|
||||
be_a(Admin::Metrics::Dimension::InstanceAccountsDimension),
|
||||
be_a(Admin::Metrics::Dimension::InstanceLanguagesDimension)
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
22
spec/lib/admin/metrics/measure_spec.rb
Normal file
22
spec/lib/admin/metrics/measure_spec.rb
Normal file
@ -0,0 +1,22 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
describe Admin::Metrics::Measure do
|
||||
describe '.retrieve' do
|
||||
subject { described_class.retrieve(reports, start_at, end_at, params) }
|
||||
|
||||
let(:start_at) { 2.days.ago }
|
||||
let(:end_at) { Time.now.utc }
|
||||
let(:params) { ActionController::Parameters.new({ instance_accounts: [123], instance_followers: [123] }) }
|
||||
let(:reports) { [:instance_accounts, :instance_followers] }
|
||||
|
||||
it 'returns instances of provided classes' do
|
||||
expect(subject)
|
||||
.to contain_exactly(
|
||||
be_a(Admin::Metrics::Measure::InstanceAccountsMeasure),
|
||||
be_a(Admin::Metrics::Measure::InstanceFollowersMeasure)
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue
Block a user