Skip to content

Commit 89ae950

Browse files
authored
Merge pull request #4 from Bulletdev/PS02
fix: adjust into to model 4 show custom order
2 parents 8892c96 + bc26972 commit 89ae950

6 files changed

Lines changed: 32 additions & 3 deletions

File tree

.github/workflows/load-test.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,11 @@ on:
2626
# # Run smoke test nightly at 2am UTC
2727
# - cron: '0 2 * * *'
2828

29+
permissions:
30+
contents: read
31+
pull-requests: write
32+
issues: write
33+
2934
env:
3035
K6_VERSION: '0.47.0'
3136

.github/workflows/nightly-security.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ on:
77
# - cron: '0 1 * * *'
88
workflow_dispatch:
99

10+
permissions:
11+
contents: read
12+
issues: write
13+
1014
jobs:
1115
full-security-audit:
1216
name: Complete Security Audit

.github/workflows/security-scan.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@ on:
1010
# # Run weekly on Monday at 9am UTC
1111
# - cron: '0 9 * * 1'
1212

13+
permissions:
14+
contents: read
15+
pull-requests: write
16+
issues: write
17+
1318
jobs:
1419
brakeman:
1520
name: Brakeman Security Scan

app/controllers/api/v1/dashboard_controller.rb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,11 @@ def active_goals_data
109109
def roster_status_data
110110
players = organization_scoped(Player).includes(:champion_pools)
111111

112+
# Order by role to ensure consistent order in by_role hash
113+
by_role_ordered = players.ordered_by_role.group(:role).count
114+
112115
{
113-
by_role: players.group(:role).count,
116+
by_role: by_role_ordered,
114117
by_status: players.group(:status).count,
115118
contracts_expiring: players.contracts_expiring_soon.count
116119
}

app/controllers/api/v1/players_controller.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ def index
1414
players = players.where('summoner_name ILIKE ? OR real_name ILIKE ?', search_term, search_term)
1515
end
1616

17-
# Pagination
18-
result = paginate(players.order(:role, :summoner_name))
17+
# Pagination - order by role (top, jungle, mid, adc, support) then by name
18+
result = paginate(players.ordered_by_role.order(:summoner_name))
1919

2020
render_success({
2121
players: PlayerSerializer.render_as_hash(result[:data]),

app/models/player.rb

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,18 @@ class Player < ApplicationRecord
3838
where(contract_end_date: Date.current..Date.current + days.days)
3939
}
4040
scope :by_tier, ->(tier) { where(solo_queue_tier: tier) }
41+
scope :ordered_by_role, -> {
42+
order(Arel.sql(
43+
"CASE role
44+
WHEN 'top' THEN 1
45+
WHEN 'jungle' THEN 2
46+
WHEN 'mid' THEN 3
47+
WHEN 'adc' THEN 4
48+
WHEN 'support' THEN 5
49+
ELSE 6
50+
END"
51+
))
52+
}
4153

4254
# Instance methods
4355
def current_rank_display

0 commit comments

Comments
 (0)