PERF: Dematerialize topic_reply_count (#9769)

* PERF: Dematerialize topic_reply_count

It's only ever used for trust level promotions that run daily, or compared to 0. We don't need to track it on every post creation.

* UX: Add symbol in TL3 report if topic reply count is capped

* DEV: Drop user_stats.topic_reply_count column
This commit is contained in:
Kane York
2020-05-14 15:42:00 -07:00
committed by GitHub
parent 675c9c38c8
commit 869f9b20a2
19 changed files with 73 additions and 119 deletions

View File

@ -58,7 +58,6 @@ class ImportScripts::Base
update_post_timings
update_feature_topic_users
update_category_featured_topics
update_topic_count_replies
reset_topic_counters
end
@ -690,19 +689,6 @@ class ImportScripts::Base
end
def update_user_stats
puts "", "Updating topic reply counts..."
count = 0
total = User.real.count
User.real.find_each do |u|
u.create_user_stat if u.user_stat.nil?
us = u.user_stat
us.update_topic_reply_count
us.save
print_status(count += 1, total, get_start_time("user_stats"))
end
puts "", "Updating first_post_created_at..."
DB.exec <<~SQL
@ -807,19 +793,6 @@ class ImportScripts::Base
end
end
def update_topic_count_replies
puts "", "Updating user topic reply counts"
count = 0
total = User.real.count
User.real.find_each do |u|
u.user_stat.update_topic_reply_count
u.user_stat.save!
print_status(count += 1, total, get_start_time("topic_count_replies"))
end
end
def update_tl0
puts "", "Setting users with no posts to trust level 0"