From bbf74498f57513751f3506e3bbf7a04be4ad3b67 Mon Sep 17 00:00:00 2001 From: Claire Date: Mon, 7 Nov 2022 22:35:53 +0100 Subject: Fix validation error in SynchronizeFeaturedTagsCollectionWorker (#20018) * Fix followers count not being updated when migrating follows Fixes #19900 * Fix validation error in SynchronizeFeaturedTagsCollectionWorker Also saves remote user's chosen case for hashtags * Limit remote featured tags before validation --- app/models/featured_tag.rb | 2 ++ 1 file changed, 2 insertions(+) (limited to 'app/models') diff --git a/app/models/featured_tag.rb b/app/models/featured_tag.rb index 78185b2a9..debae2212 100644 --- a/app/models/featured_tag.rb +++ b/app/models/featured_tag.rb @@ -63,6 +63,8 @@ class FeaturedTag < ApplicationRecord end def validate_featured_tags_limit + return unless account.local? + errors.add(:base, I18n.t('featured_tags.errors.limit')) if account.featured_tags.count >= LIMIT end -- cgit From ca80beb6530b3bbeff795c4832e2b4ab7bc8f672 Mon Sep 17 00:00:00 2001 From: Postmodern Date: Mon, 7 Nov 2022 18:50:47 -0800 Subject: Micro-optimization: use `if`/`else` instead of `Array#compact` and `Array#min` (#19906) * Technically `if`/`else` is faster than using `[value1, value2].compact.min` to find the lesser of two values, one of which may be `nil`. --- app/models/account_statuses_cleanup_policy.rb | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'app/models') diff --git a/app/models/account_statuses_cleanup_policy.rb b/app/models/account_statuses_cleanup_policy.rb index 365123653..49adc6ad0 100644 --- a/app/models/account_statuses_cleanup_policy.rb +++ b/app/models/account_statuses_cleanup_policy.rb @@ -139,7 +139,12 @@ class AccountStatusesCleanupPolicy < ApplicationRecord # Filtering on `id` rather than `min_status_age` ago will treat # non-snowflake statuses as older than they really are, but Mastodon # has switched to snowflake IDs significantly over 2 years ago anyway. - max_id = [max_id, Mastodon::Snowflake.id_at(min_status_age.seconds.ago, with_random: false)].compact.min + snowflake_id = Mastodon::Snowflake.id_at(min_status_age.seconds.ago, with_random: false) + + if max_id.nil? || snowflake_id < max_id + max_id = snowflake_id + end + Status.where(Status.arel_table[:id].lteq(max_id)) end -- cgit