From c2b498a2b0035bdeec1028e58f4914eefcac80a4 Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Thu, 31 Oct 2024 10:38:00 +0100 Subject: [PATCH] Fix IDs not being serialized as strings in annual reports API (#32710) --- app/lib/annual_report/commonly_interacted_with_accounts.rb | 2 +- app/lib/annual_report/most_reblogged_accounts.rb | 2 +- app/lib/annual_report/top_statuses.rb | 6 +++--- .../annual_report/commonly_interacted_with_accounts_spec.rb | 2 +- spec/lib/annual_report/most_reblogged_accounts_spec.rb | 2 +- spec/lib/annual_report/top_statuses_spec.rb | 6 +++--- 6 files changed, 10 insertions(+), 10 deletions(-) diff --git a/app/lib/annual_report/commonly_interacted_with_accounts.rb b/app/lib/annual_report/commonly_interacted_with_accounts.rb index e7482f0d52a..30ab671d8a8 100644 --- a/app/lib/annual_report/commonly_interacted_with_accounts.rb +++ b/app/lib/annual_report/commonly_interacted_with_accounts.rb @@ -7,7 +7,7 @@ class AnnualReport::CommonlyInteractedWithAccounts < AnnualReport::Source { commonly_interacted_with_accounts: commonly_interacted_with_accounts.map do |(account_id, count)| { - account_id: account_id, + account_id: account_id.to_s, count: count, } end, diff --git a/app/lib/annual_report/most_reblogged_accounts.rb b/app/lib/annual_report/most_reblogged_accounts.rb index 39ed3868ea0..cfc4022ca79 100644 --- a/app/lib/annual_report/most_reblogged_accounts.rb +++ b/app/lib/annual_report/most_reblogged_accounts.rb @@ -7,7 +7,7 @@ class AnnualReport::MostRebloggedAccounts < AnnualReport::Source { most_reblogged_accounts: most_reblogged_accounts.map do |(account_id, count)| { - account_id: account_id, + account_id: account_id.to_s, count: count, } end, diff --git a/app/lib/annual_report/top_statuses.rb b/app/lib/annual_report/top_statuses.rb index c5abeaa58d8..74b129595ac 100644 --- a/app/lib/annual_report/top_statuses.rb +++ b/app/lib/annual_report/top_statuses.rb @@ -8,9 +8,9 @@ class AnnualReport::TopStatuses < AnnualReport::Source { top_statuses: { - by_reblogs: top_reblogs, - by_favourites: top_favourites, - by_replies: top_replies, + by_reblogs: top_reblogs&.to_s, + by_favourites: top_favourites&.to_s, + by_replies: top_replies&.to_s, }, } end diff --git a/spec/lib/annual_report/commonly_interacted_with_accounts_spec.rb b/spec/lib/annual_report/commonly_interacted_with_accounts_spec.rb index e99d3cb4a78..0e31827912b 100644 --- a/spec/lib/annual_report/commonly_interacted_with_accounts_spec.rb +++ b/spec/lib/annual_report/commonly_interacted_with_accounts_spec.rb @@ -32,7 +32,7 @@ RSpec.describe AnnualReport::CommonlyInteractedWithAccounts do expect(subject.generate) .to include( commonly_interacted_with_accounts: contain_exactly( - include(account_id: other_account.id, count: 2) + include(account_id: other_account.id.to_s, count: 2) ) ) end diff --git a/spec/lib/annual_report/most_reblogged_accounts_spec.rb b/spec/lib/annual_report/most_reblogged_accounts_spec.rb index 0280ba19928..2f04934e477 100644 --- a/spec/lib/annual_report/most_reblogged_accounts_spec.rb +++ b/spec/lib/annual_report/most_reblogged_accounts_spec.rb @@ -32,7 +32,7 @@ RSpec.describe AnnualReport::MostRebloggedAccounts do expect(subject.generate) .to include( most_reblogged_accounts: contain_exactly( - include(account_id: other_account.id, count: 2) + include(account_id: other_account.id.to_s, count: 2) ) ) end diff --git a/spec/lib/annual_report/top_statuses_spec.rb b/spec/lib/annual_report/top_statuses_spec.rb index b956b039735..af29df1f651 100644 --- a/spec/lib/annual_report/top_statuses_spec.rb +++ b/spec/lib/annual_report/top_statuses_spec.rb @@ -39,9 +39,9 @@ RSpec.describe AnnualReport::TopStatuses do expect(subject.generate) .to include( top_statuses: include( - by_reblogs: reblogged_status.id, - by_favourites: favourited_status.id, - by_replies: replied_status.id + by_reblogs: reblogged_status.id.to_s, + by_favourites: favourited_status.id.to_s, + by_replies: replied_status.id.to_s ) ) end