* Initial automatic cleanup with rubocop * Fix syntax error introduced by rubocop * Cleanup seeds file * Cleanup lib folder * Exclude bin folder because it contains auto generated files * Make Rubocop a little bit more chatty * Block length should not include comments in the count * Cleanup config folder * Cleanup specs * Updated Rubocop version and generated a todo file * Fix broken ArticlesApi spec * Fix tests * Restored rubocop pre-commit hook
25 lines
996 B
Ruby
25 lines
996 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)
|
|
@comments_this_week = Comment.where(user_id: @team_members.pluck(:id)).where("created_at > ?", Date.today.beginning_of_week).pluck(:user_id)
|
|
@comment_totals_this_week = frequency(@comments_this_week)
|
|
@comments_24_hours = Comment.where(user_id: @team_members.pluck(:id)).where("created_at > ?", 24.hours.ago).pluck(:user_id)
|
|
@comment_totals_24_hours = frequency(@comments_24_hours)
|
|
end
|
|
|
|
def frequency(a)
|
|
a.group_by do |e|
|
|
e
|
|
end.map do |key, values|
|
|
{ number_of_comments: values.size, username: User.find(key).username }
|
|
end.sort_by { |hsh| hsh[:number_of_comments] }.reverse!
|
|
end
|
|
end
|