diff --git a/app/lib/admin/metrics/dimension.rb b/app/lib/admin/metrics/dimension.rb index e0122a65b..824cb6d7c 100644 --- a/app/lib/admin/metrics/dimension.rb +++ b/app/lib/admin/metrics/dimension.rb @@ -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) diff --git a/app/lib/admin/metrics/measure.rb b/app/lib/admin/metrics/measure.rb index fe7e04929..d23162dfa 100644 --- a/app/lib/admin/metrics/measure.rb +++ b/app/lib/admin/metrics/measure.rb @@ -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) diff --git a/spec/lib/admin/metrics/dimension_spec.rb b/spec/lib/admin/metrics/dimension_spec.rb new file mode 100644 index 000000000..109250b72 --- /dev/null +++ b/spec/lib/admin/metrics/dimension_spec.rb @@ -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 diff --git a/spec/lib/admin/metrics/measure_spec.rb b/spec/lib/admin/metrics/measure_spec.rb new file mode 100644 index 000000000..c9809b0f7 --- /dev/null +++ b/spec/lib/admin/metrics/measure_spec.rb @@ -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