gab-social/lib/tasks/fix_account_stats.rake

17 lines
583 B
Ruby
Raw Normal View History

2019-07-04 00:27:50 +01:00
# frozen_string_literal: true
task fix_account_stats: 'gabsocial:fix-account-stats'
namespace :gabsocial do
desc 'Re-compute user statistics (following cnt, followers cnt, etc.)'
task :fix_account_stats => :environment do
Account.select(:id, :username).all.each do |a|
a.account_stat.following_count = Follow.where(account_id: a.id).count
a.account_stat.followers_count = Follow.where(target_account_id: a.id).count
a.account_stat.statuses_count = Status.where(account_id: a.id).count
a.account_stat.save!
2019-07-04 00:31:10 +01:00
# puts(a.username)
2019-07-04 00:27:50 +01:00
end
end
end