Move account counters to separate table#9295
Conversation
There was a problem hiding this comment.
i think this should maybe be attributes[key]? or something similar, i can't remember the precise syntax offhand.
There was a problem hiding this comment.
That's if the counter was on the same table as before. We want to call the explicitly defined followers_count method here.
7971ab1 to
12e6781
Compare
There was a problem hiding this comment.
Note: This query has been wrong for a long time. I think it hasn't been updated since ActivityPub was introduced. It would send PuSH subscriptions to ActivityPub accounts. It also would not correctly filter accounts that had local followers. So this is a net improvement.
There was a problem hiding this comment.
should be delegate :statuses_count, :statuses_count=, :following_count, :following_count=, :followers_count, :followers_count=, to: :account_stat
and then handle the case of nil account_stat in the set_account_stat hook
There was a problem hiding this comment.
%w(statuses following followers).flat_map { |i| [:"#{i}_count", :"#{i}_count=" } is even a little cuter, your call.
There was a problem hiding this comment.
per our conversation, this should handle migrating the counts from the existing record if there's no account_stat record.
12e6781 to
397b4e9
Compare
There was a problem hiding this comment.
i think these should live on AccountStat and be delegated also
There was a problem hiding this comment.
and then we don't need to care about this method
397b4e9 to
2efad1f
Compare
2efad1f to
4bf0f20
Compare
statuses_countis the most updated column probably among all tables, because it goes up every time you post a new status. By extracting it to a table with only a few columns, updates can run faster and the dead tuples left behind until next vacuum are smaller.Fix #7908
Instructions:
SKIP_POST_DEPLOYMENT_MIGRATIONS=true rails db:migratefirst