Skip to content

Commit

Permalink
Merge pull request #146 from ezraroi/145-main-dashboard-mark-graph-pe…
Browse files Browse the repository at this point in the history
…r-game-is-with-wrong-team-icons

fixed
  • Loading branch information
ezraroi authored Nov 29, 2024
2 parents af805bd + da3c6b9 commit d1c3ef7
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 20 deletions.
18 changes: 10 additions & 8 deletions Mundialito/Client/src/Dashboard/DashboardCtrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,17 @@ angular.module('mundialitoApp').controller('DashboardCtrl', ['$scope', '$log', '
$scope.players = players;

// Function to group teams by ShortName
function groupTeamsByShortName(teams) {
function groupTeamsByName(teams) {
return teams.reduce((acc, team) => {
const shortName = team.ShortName;
if (!acc[shortName]) {
acc[shortName] = [];
const name = team.Name;
if (!acc[name]) {
acc[name] = [];
}
acc[shortName].push(team);
acc[name].push(team);
return acc;
}, {});
}
$scope.groupedTeams = groupTeamsByShortName(teams);
$scope.groupedTeams = groupTeamsByName(teams);

$scope.changed = (game) => {
if ($scope.toggleValue[game.GameId]) {
Expand All @@ -33,6 +33,8 @@ angular.module('mundialitoApp').controller('DashboardCtrl', ['$scope', '$log', '
}

$scope.getGamesPromise = GamesManager.loadAllGames().then((games) => {
games.forEach(game => {
game.IsPendingUpdate = true });
$scope.games = games;
$scope.resultsDic = {};
$scope.marksDic = {};
Expand All @@ -51,9 +53,9 @@ angular.module('mundialitoApp').controller('DashboardCtrl', ['$scope', '$log', '
return 'X';
}
if (bet.HomeScore > bet.AwayScore) {
return bet.Game.HomeTeam.ShortName;
return bet.Game.HomeTeam.Name;
}
return bet.Game.AwayTeam.ShortName;
return bet.Game.AwayTeam.Name;
});
$scope.resultsDic[game.GameId] = Object.entries(resulsGrouped).sort((a, b) => b[1].length - a[1].length);
$scope.marksDic[game.GameId] = Object.entries(marksGrouped).sort((a, b) => b[1].length - a[1].length);
Expand Down
2 changes: 1 addition & 1 deletion Mundialito/Controllers/GamesController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ public ActionResult<IEnumerable<BetViewModel>> GetGameBets(int id)
if (game == null)
return NotFound(new ErrorMessage { Message = string.Format("Game with id '{0}' not found", id) });
if (game.IsOpen(dateTimeProvider.UTCNow))
return BadRequest(new ErrorMessage { Message = String.Format("Game '{0}' is stil open for betting", id) });
return BadRequest(new ErrorMessage { Message = string.Format("Game '{0}' is stil open for betting", id) });
return Ok(betsRepository.GetGameBets(id).Select(item => new BetViewModel(item, dateTimeProvider.UTCNow)).OrderByDescending(bet => bet.Points));
}

Expand Down
4 changes: 2 additions & 2 deletions Mundialito/Views/Home/Index.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -149,11 +149,11 @@
@if (env.IsProduction())
{
<script src="lib/lib-min-2d5e40df8764ea1d842fca768d139b58.js"></script>
<script src="js/app-min-7650b9735dadd2976bd3e012a2ea28c6.js"></script>
<script src="js/app-min-e666197beb692f9889d32895cfc5320d.js"></script>
}
else {
<script src="lib/lib-77990d6df268e8d3d432fb52597000f9.js"></script>
<script src="js/app-96f22219e28d4994f79433c0d1d5ec4c.js"></script>
<script src="js/app-ef83d0c9d9c3c542a9adfaae48203158.js"></script>
}
<script>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -674,17 +674,17 @@ angular.module('mundialitoApp').controller('DashboardCtrl', ['$scope', '$log', '
$scope.players = players;

// Function to group teams by ShortName
function groupTeamsByShortName(teams) {
function groupTeamsByName(teams) {
return teams.reduce((acc, team) => {
const shortName = team.ShortName;
if (!acc[shortName]) {
acc[shortName] = [];
const name = team.Name;
if (!acc[name]) {
acc[name] = [];
}
acc[shortName].push(team);
acc[name].push(team);
return acc;
}, {});
}
$scope.groupedTeams = groupTeamsByShortName(teams);
$scope.groupedTeams = groupTeamsByName(teams);

$scope.changed = (game) => {
if ($scope.toggleValue[game.GameId]) {
Expand All @@ -697,6 +697,8 @@ angular.module('mundialitoApp').controller('DashboardCtrl', ['$scope', '$log', '
}

$scope.getGamesPromise = GamesManager.loadAllGames().then((games) => {
games.forEach(game => {
game.IsPendingUpdate = true });
$scope.games = games;
$scope.resultsDic = {};
$scope.marksDic = {};
Expand All @@ -715,9 +717,9 @@ angular.module('mundialitoApp').controller('DashboardCtrl', ['$scope', '$log', '
return 'X';
}
if (bet.HomeScore > bet.AwayScore) {
return bet.Game.HomeTeam.ShortName;
return bet.Game.HomeTeam.Name;
}
return bet.Game.AwayTeam.ShortName;
return bet.Game.AwayTeam.Name;
});
$scope.resultsDic[game.GameId] = Object.entries(resulsGrouped).sort((a, b) => b[1].length - a[1].length);
$scope.marksDic[game.GameId] = Object.entries(marksGrouped).sort((a, b) => b[1].length - a[1].length);
Expand Down

This file was deleted.

Large diffs are not rendered by default.

0 comments on commit d1c3ef7

Please sign in to comment.