docbrown/app/controllers/internal/dogfood_controller.rb
Araslanov Evgeny 97d9b836a7 Improve DogFoodController's querying (#350)
query with INNER JOIN and COUNT
2018-08-31 15:54:33 -04:00

20 lines
664 B
Ruby

class Internal::DogfoodController < Internal::ApplicationController
layout "internal"
def index
usernames = if Rails.env.production?
["ben", "jess", "peter", "maestromac", "andy", "lianafelt"]
else
["thepracticaldev", "bendhalpern"]
end
@team_members = User.where(username: usernames).order(comments_count: :desc)
user_ids = @team_members.map(&:id)
@comment_totals_this_week = Comment.
users_with_number_of_comments(user_ids, Date.today.beginning_of_week)
@comment_totals_24_hours = Comment.
users_with_number_of_comments(user_ids, 24.hours.ago)
end
end