Fix tootctl feeds build not building list timelines (#33783)

This commit is contained in:
Claire 2025-01-30 10:18:46 +01:00 committed by GitHub
parent 3f4f6317d4
commit a3d2849d15
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 95 additions and 18 deletions

View file

@ -301,6 +301,38 @@ class FeedManager
end
end
# Populate list feed of account from scratch
# @param [List] list
# @return [void]
def populate_list(list)
limit = FeedManager::MAX_ITEMS / 2
aggregate = list.account.user&.aggregates_reblogs?
timeline_key = key(:list, list.id)
list.active_accounts.includes(:account_stat).reorder(nil).find_each do |target_account|
if redis.zcard(timeline_key) >= limit
oldest_home_score = redis.zrange(timeline_key, 0, 0, with_scores: true).first.last.to_i
last_status_score = Mastodon::Snowflake.id_at(target_account.last_status_at)
# If the feed is full and this account has not posted more recently
# than the last item on the feed, then we can skip the whole account
# because none of its statuses would stay on the feed anyway
next if last_status_score < oldest_home_score
end
statuses = target_account.statuses.list_eligible_visibility.includes(:preloadable_poll, :media_attachments, :account, reblog: :account).limit(limit)
crutches = build_crutches(list.account_id, statuses)
statuses.each do |status|
next if filter_from_home(status, list.account_id, crutches) || filter_from_list?(status, list)
add_to_feed(:list, list.id, status, aggregate_reblogs: aggregate)
end
trim(:list, list.id)
end
end
# Completely clear multiple feeds at once
# @param [Symbol] type
# @param [Array<Integer>] ids

View file

@ -24,6 +24,7 @@ class List < ApplicationRecord
has_many :list_accounts, inverse_of: :list, dependent: :destroy
has_many :accounts, through: :list_accounts
has_many :active_accounts, -> { merge(ListAccount.active) }, through: :list_accounts, source: :account
validates :title, presence: true

View file

@ -20,6 +20,8 @@ class ListAccount < ApplicationRecord
validates :account_id, uniqueness: { scope: :list_id }
validate :validate_relationship
scope :active, -> { where.not(follow_id: nil) }
before_validation :set_follow, unless: :list_owner_account_is_account?
private

View file

@ -5,6 +5,10 @@ class PrecomputeFeedService < BaseService
def call(account)
FeedManager.instance.populate_home(account)
account.owned_lists.each do |list|
FeedManager.instance.populate_list(list)
end
ensure
redis.del("account:#{account.id}:regeneration")
end