When get the sum of some objects: pluck.sum can be changed to sum()

app/models/trust_level3_requirements.rb:

user.user_visits.where('visited_at > ?', time_period.days.ago).pluck(:posts_read).sum
app/models/trust_level3_requirements.rb:    user.user_visits.pluck(:posts_read).sum

could be changed to

user.user_visits.where('visited_at > ?', time_period.days.ago).sum(:posts_read)
user.user_visits.sum(:posts_read)

since doing sum directly under db is faster than pluck and sum

Yeah, that sound right, @neil was there a reason for the “pull” and then “sum” stuff there?

There probably wasn’t a good reason for pluck and sum. /shrug

Hi, it looks like you are really interesting in development of Discourse. Mind also look for some advices here to tackle on the most intricate problems?

Thank you for the GitHub pull requests at https://github.com/discourse/discourse @junwen_yang! :hugs: