Merge remote-tracking branch 'parent/main' into kb_migration

This commit is contained in:
KMY 2023-08-20 08:37:27 +09:00
commit d1a76ea317
20 changed files with 447 additions and 280 deletions

View file

@ -2,7 +2,7 @@
# == Schema Information
#
# Table name: follow_recommendations
# Table name: global_follow_recommendations
#
# account_id :bigint(8) primary key
# rank :decimal(, )
@ -11,6 +11,7 @@
class FollowRecommendation < ApplicationRecord
self.primary_key = :account_id
self.table_name = :global_follow_recommendations
belongs_to :account_summary, foreign_key: :account_id, inverse_of: false
belongs_to :account

View file

@ -466,13 +466,25 @@ class Status < ApplicationRecord
account_ids.uniq!
status_ids = cached_items.map { |item| item.reblog? ? item.reblog_of_id : item.id }.uniq
return if account_ids.empty?
accounts = Account.where(id: account_ids).includes(:account_stat, :user).index_by(&:id)
status_stats = StatusStat.where(status_id: status_ids).index_by(&:status_id)
cached_items.each do |item|
item.account = accounts[item.account_id]
item.reblog.account = accounts[item.reblog.account_id] if item.reblog?
if item.reblog?
status_stat = status_stats[item.reblog.id]
item.reblog.status_stat = status_stat if status_stat.present?
else
status_stat = status_stats[item.id]
item.status_stat = status_stat if status_stat.present?
end
end
end