Remove more unused data from 2025 annual reports (#37134)

This commit is contained in:
Claire
2025-12-05 14:36:37 +01:00
committed by GitHub
parent 591776d7ad
commit 9b851616fe
8 changed files with 1 additions and 140 deletions

View File

@@ -42,13 +42,6 @@ interface AnnualReportV2 {
time_series: TimeSeriesMonth[];
top_hashtags: NameAndCount[];
top_statuses: TopStatuses;
most_used_apps: NameAndCount[];
type_distribution: {
total: number;
reblogs: number;
replies: number;
standalone: number;
};
}
export type AnnualReport = {

View File

@@ -5,9 +5,7 @@ class AnnualReport
SOURCES = [
AnnualReport::Archetype,
AnnualReport::TypeDistribution,
AnnualReport::TopStatuses,
AnnualReport::MostUsedApps,
AnnualReport::TimeSeries,
AnnualReport::TopHashtags,
].freeze

View File

@@ -1,22 +0,0 @@
# frozen_string_literal: true
class AnnualReport::MostUsedApps < AnnualReport::Source
SET_SIZE = 10
def generate
{
most_used_apps: most_used_apps.map do |(name, count)|
{
name: name,
count: count,
}
end,
}
end
private
def most_used_apps
report_statuses.joins(:application).group(oauth_applications: [:name]).order(count_all: :desc).limit(SET_SIZE).count
end
end

View File

@@ -2,7 +2,7 @@
class AnnualReport::TopHashtags < AnnualReport::Source
MINIMUM_TAGGINGS = 1
SET_SIZE = 5
SET_SIZE = 1
def generate
{

View File

@@ -1,14 +0,0 @@
# frozen_string_literal: true
class AnnualReport::TypeDistribution < AnnualReport::Source
def generate
{
type_distribution: {
total: report_statuses.count,
reblogs: report_statuses.only_reblogs.count,
replies: report_statuses.where.not(in_reply_to_id: nil).not_replying_to_account(@account).count,
standalone: report_statuses.without_replies.without_reblogs.count,
},
}
end
end

View File

@@ -1,45 +0,0 @@
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe AnnualReport::MostUsedApps do
describe '#generate' do
subject { described_class.new(account, Time.zone.now.year) }
context 'with an inactive account' do
let(:account) { Fabricate :account }
it 'builds a report for an account' do
expect(subject.generate)
.to include(
most_used_apps: be_an(Array).and(be_empty)
)
end
end
context 'with an active account' do
let(:account) { Fabricate :account }
let(:application) { Fabricate :application, name: 'App' }
let(:most_application) { Fabricate :application, name: 'Most App' }
before do
_other = Fabricate :status
Fabricate.times 2, :status, account: account, application: application
Fabricate.times 3, :status, account: account, application: most_application
end
it 'builds a report for an account' do
expect(subject.generate)
.to include(
most_used_apps: eq(
[
{ name: most_application.name, count: 3 },
{ name: application.name, count: 2 },
]
)
)
end
end
end
end

View File

@@ -44,7 +44,6 @@ RSpec.describe AnnualReport::TopHashtags do
top_hashtags: eq(
[
{ name: most_tag.name, count: 3 },
{ name: tag.name, count: 2 },
]
)
)

View File

@@ -1,48 +0,0 @@
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe AnnualReport::TypeDistribution do
describe '#generate' do
subject { described_class.new(account, Time.zone.now.year) }
context 'with an inactive account' do
let(:account) { Fabricate :account }
it 'builds a report for an account' do
expect(subject.generate)
.to include(
type_distribution: include(
total: 0,
reblogs: 0,
replies: 0,
standalone: 0
)
)
end
end
context 'with an active account' do
let(:account) { Fabricate :account }
before do
_other = Fabricate :status
Fabricate :status, reblog: Fabricate(:status), account: account
Fabricate :status, in_reply_to_id: Fabricate(:status).id, account: account, reply: true
Fabricate :status, account: account
end
it 'builds a report for an account' do
expect(subject.generate)
.to include(
type_distribution: include(
total: 3,
reblogs: 1,
replies: 1,
standalone: 1
)
)
end
end
end
end