Skip to content

Commit c7cfb30

Browse files
authored
fix: namespace inconsistence at analytics module (#14)
1. Import matches - The endpoint /api/v1/matches/import is functioning 2. View performance analytics - Graphs and statistics loading correctly 3. View KDA trends - Performance timeline per match functioning 4. Check sync status - Dashboard showing integration status with Riot API
1 parent 88e9657 commit c7cfb30

File tree

4 files changed

+20
-8
lines changed

4 files changed

+20
-8
lines changed

app/controllers/api/v1/analytics/kda_trend_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ def show
44

55
# Get recent matches for the player
66
stats = PlayerMatchStat.joins(:match)
7-
.where(player: player, match: { organization: current_organization })
7+
.where(player: player, matches: { organization_id: current_organization.id })
88
.order('matches.game_start DESC')
99
.limit(50)
1010
.includes(:match)

app/controllers/api/v1/analytics/performance_controller.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def calculate_team_overview(matches)
3838
avg_deaths_per_game: stats.average(:deaths)&.round(1),
3939
avg_assists_per_game: stats.average(:assists)&.round(1),
4040
avg_gold_per_game: stats.average(:gold_earned)&.round(0),
41-
avg_damage_per_game: stats.average(:total_damage_dealt)&.round(0),
41+
avg_damage_per_game: stats.average(:damage_dealt_total)&.round(0),
4242
avg_vision_score: stats.average(:vision_score)&.round(1)
4343
}
4444
end
@@ -70,7 +70,7 @@ def calculate_performance_by_role(matches)
7070
'AVG(player_match_stats.deaths) as avg_deaths',
7171
'AVG(player_match_stats.assists) as avg_assists',
7272
'AVG(player_match_stats.gold_earned) as avg_gold',
73-
'AVG(player_match_stats.total_damage_dealt) as avg_damage',
73+
'AVG(player_match_stats.damage_dealt_total) as avg_damage',
7474
'AVG(player_match_stats.vision_score) as avg_vision'
7575
).map do |stat|
7676
{

app/modules/matches/controllers/matches_controller.rb

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
1-
class Api::V1::MatchesController < Api::V1::BaseController
2-
before_action :set_match, only: [:show, :update, :destroy, :stats]
1+
# frozen_string_literal: true
2+
3+
module Matches
4+
module Controllers
5+
class MatchesController < Api::V1::BaseController
6+
before_action :set_match, only: [:show, :update, :destroy, :stats]
37

48
def index
59
matches = organization_scoped(Match).includes(:player_match_stats, :players)
@@ -255,5 +259,7 @@ def calculate_avg_kda(stats)
255259

256260
deaths = total_deaths.zero? ? 1 : total_deaths
257261
((total_kills + total_assists).to_f / deaths).round(2)
262+
end
263+
end
258264
end
259265
end

app/modules/riot_integration/controllers/riot_integration_controller.rb

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
1-
class Api::V1::RiotIntegrationController < Api::V1::BaseController
2-
def sync_status
1+
# frozen_string_literal: true
2+
3+
module RiotIntegration
4+
module Controllers
5+
class RiotIntegrationController < Api::V1::BaseController
6+
def sync_status
37
players = organization_scoped(Player)
48

59
total_players = players.count
@@ -36,6 +40,8 @@ def sync_status
3640
needs_sync: needs_sync
3741
},
3842
recent_syncs: recent_syncs
39-
})
43+
})
44+
end
45+
end
4046
end
4147
end

0 commit comments

Comments
 (0)