Skip to content

Commit

Permalink
show longer list
Browse files Browse the repository at this point in the history
  • Loading branch information
pjurewicz committed Oct 12, 2023
1 parent 3455c17 commit e2d4bc2
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion app/controllers/leaderboards_controller.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
class LeaderboardsController < ApplicationController
def show
team = Team.find_by(slack_team_domain: params[:team_domain])
@leaderboard = Leaderboards.new(team).top_for_this_year
@leaderboard = Leaderboards.new(team, nil).top_for_this_year
end
end
6 changes: 4 additions & 2 deletions app/models/leaderboards.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
class Leaderboards
def initialize(team)
def initialize(team, limit = 10)
@team_time_zone = team.time_zone
@team_scope = DailyStatistic.of_team(team.id)
@limit = limit
end

def top_for_this_week
Expand All @@ -22,7 +23,7 @@ def aggreated_data(scope)
scope
.group('user_name')
.order('sum_points desc')
.limit(10)
.limit(@limit)
.sum('points')
.group_by(&:second)
.map { |points, members| [points, members.map(&:first)] }.to_h
Expand All @@ -38,6 +39,7 @@ def method_missing(m, *args, &block)
end

private

def format(hash)
hash
.map { |count, members| "#{count}: #{members.join(", ")}" }
Expand Down

0 comments on commit e2d4bc2

Please sign in to comment.