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
3 « J'aime »
sam
(Sam Saffron)
Août 18, 2017, 6:24
2
Yeah, that sound right, @neil was there a reason for the “pull” and then “sum” stuff there?
neil
(Neil Lalonde)
Août 18, 2017, 6:27
3
There probably wasn’t a good reason for pluck and sum. /shrug
3 « J'aime »
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?
6 « J'aime »