Skip to content

Commit

Permalink
Merge branch 'main' into 131-integrate-sentry
Browse files Browse the repository at this point in the history
  • Loading branch information
ezraroi authored Sep 21, 2024
2 parents e0c0c1c + 1f94e08 commit 74f6198
Show file tree
Hide file tree
Showing 7 changed files with 2,914 additions and 20 deletions.
11 changes: 8 additions & 3 deletions Mundialito/Client/src/Dashboard/Dashboard.html
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,12 @@ <h6><small>{{::game.AwayTeam.Name}}</small></h6>
<uib-accordion-heading>
<div class="row">
<div class="col-md-1 col-xs-2 text-center">
<span class="badge">{{item[0]}}</span>
<div ng-if="groupedTeams[item[0]] === undefined">
<span class="badge">{{item[0]}}</span>
</div>
<div ng-if="groupedTeams[item[0]] !== undefined">
<team-flag team="groupedTeams[item[0]][0]"></team-flag>
</div>
</div>
<div class="col-md-10 col-xs-9">
<uib-progressbar max="100" min="0"
Expand Down Expand Up @@ -263,8 +268,8 @@ <h4 class="media-heading"><a href="{{user.getUrl()}}">{{user.Place}}.
<tr ng-repeat="bet in generalBets">
<td>{{bet.OwnerName}}</td>
<td>{{usersDic[bet.OwnerId].Points}}</td>
<td>{{teamsDic[bet.WinningTeamId].Name}}</td>
<td>{{playersDic[bet.GoldenBootPlayerId].Name}}</td>
<td>{{bet.WinningTeam.Name}}</td>
<td>{{bet.GoldenBootPlayer.Name}}</td>
</tr>
</tbody>
</table>
Expand Down
13 changes: 13 additions & 0 deletions Mundialito/Client/src/Dashboard/DashboardCtrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,19 @@ angular.module('mundialitoApp').controller('DashboardCtrl', ['$scope', '$log', '
$scope.toggleValue = {};
$scope.players = players;

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

$scope.changed = (game) => {
if ($scope.toggleValue[game.GameId]) {
$scope.selectedDic[game.GameId] = $scope.marksDic[game.GameId];
Expand Down
14 changes: 7 additions & 7 deletions Mundialito/Controllers/StatsController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public async Task<ActionResult<StatsModel>> GetStats(string username)

private async Task<ActionResult<StatsModel>> CalcStats(MundialitoUser requestedUser, MundialitoUser loggedUser, IEnumerable<MundialitoUser> followees)
{
var games = (float)gamesRepository.GetGames().Count();
var games = (float)gamesRepository.GetGames().Where((game) => game.IsBetResolved()).Count();
var users = (float)userManager.Users.Count();
var bets = betsRepository.GetBets().Where((bet) => bet.IsResolved()).ToList();
var table = tableBuilder.GetTable(userManager.Users.Select((user) => new UserWithPointsModel(user)), bets, generalBetsRepository.GetGeneralBets());
Expand Down Expand Up @@ -198,12 +198,12 @@ private PerGameModel getResultProbability(float games, float users, List<Bet> be

private PerGameModel getNumOfBingo(float games, float users, List<Bet> bets, MundialitoUser user, MundialitoUser loggedUser, MundialitoUser leader, IEnumerable<MundialitoUser> followees)
{
var best = bets.GroupBy((bet) => bet.User.FirstName + " " + bet.User.LastName).ToDictionary(g => g.Key, g => g.Where((bet) => bet.Points == 7).Count()).OrderByDescending(x => x.Value).FirstOrDefault();
var requested = bets.Where((bet) => bet.User.UserName == user.UserName).Where((bet) => bet.Points == 7).Count();
var followeesRes = bets.Where((bet) => followees.Where((fol) => fol.UserName == bet.User.UserName).Any()).Where((bet) => bet.Points == 7).Count();
var logged = bets.Where((bet) => bet.User.UserName == loggedUser.UserName).Where((bet) => bet.Points == 7).Count();
var leaderBingo = bets.Where((bet) => bet.User.UserName == leader.UserName).Where((bet) => bet.Points == 7).Count();
var all = bets.Where((bet) => bet.Points == 7).Count();
var best = bets.GroupBy((bet) => bet.User.FirstName + " " + bet.User.LastName).ToDictionary(g => g.Key, g => g.Where((bet) => bet.MaxPoints).Count()).OrderByDescending(x => x.Value).FirstOrDefault();
var requested = bets.Where((bet) => bet.User.UserName == user.UserName).Where((bet) => bet.MaxPoints).Count();
var followeesRes = bets.Where((bet) => followees.Where((fol) => fol.UserName == bet.User.UserName).Any()).Where((bet) => bet.MaxPoints).Count();
var logged = bets.Where((bet) => bet.User.UserName == loggedUser.UserName).Where((bet) => bet.MaxPoints).Count();
var leaderBingo = bets.Where((bet) => bet.User.UserName == leader.UserName).Where((bet) => bet.MaxPoints).Count();
var all = bets.Where((bet) => bet.MaxPoints).Count();
return new PerGameModel
{
You = logged,
Expand Down
14 changes: 7 additions & 7 deletions Mundialito/DAL/Games/GameExtensionMethods.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,34 +2,34 @@

public static class GameExtensionMethods
{
public static Boolean IsOpen(this Game game)
public static bool IsOpen(this Game game)
{
return game.IsOpen(DateTime.UtcNow);
}

public static Boolean IsOpen(this Game game, DateTime now)
public static bool IsOpen(this Game game, DateTime now)
{
return now < game.CloseTime;
}

public static Boolean IsPendingUpdate(this Game game)
public static bool IsPendingUpdate(this Game game)
{
return game.IsPendingUpdate(DateTime.UtcNow);
}

public static Boolean IsPendingUpdate(this Game game, DateTime now)
public static bool IsPendingUpdate(this Game game, DateTime now)
{
if (game.IsOpen(now))
return false;
return game.HomeScore == null || game.AwayScore == null || game.CardsMark == null || game.CornersMark == null;
}

public static Boolean IsBetResolved(this Game game)
public static bool IsBetResolved(this Game game)
{
return game.IsBetResolved(DateTime.UtcNow);
}

public static Boolean IsBetResolved(this Game game, DateTime now)
public static bool IsBetResolved(this Game game, DateTime now)
{
return !game.IsOpen(now) && !game.IsPendingUpdate(now);
}
Expand All @@ -40,7 +40,7 @@ public static String Mark(this Game game)
return game.Mark(DateTime.UtcNow);
}

public static String Mark(this Game game, DateTime now)
public static string Mark(this Game game, DateTime now)
{
if (!game.IsOpen(now))
{
Expand Down
11 changes: 8 additions & 3 deletions Mundialito/wwwroot/App/Dashboard/Dashboard.html
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,12 @@ <h6><small>{{::game.AwayTeam.Name}}</small></h6>
<uib-accordion-heading>
<div class="row">
<div class="col-md-1 col-xs-2 text-center">
<span class="badge">{{item[0]}}</span>
<div ng-if="groupedTeams[item[0]] === undefined">
<span class="badge">{{item[0]}}</span>
</div>
<div ng-if="groupedTeams[item[0]] !== undefined">
<team-flag team="groupedTeams[item[0]][0]"></team-flag>
</div>
</div>
<div class="col-md-10 col-xs-9">
<uib-progressbar max="100" min="0"
Expand Down Expand Up @@ -263,8 +268,8 @@ <h4 class="media-heading"><a href="{{user.getUrl()}}">{{user.Place}}.
<tr ng-repeat="bet in generalBets">
<td>{{bet.OwnerName}}</td>
<td>{{usersDic[bet.OwnerId].Points}}</td>
<td>{{teamsDic[bet.WinningTeamId].Name}}</td>
<td>{{playersDic[bet.GoldenBootPlayerId].Name}}</td>
<td>{{bet.WinningTeam.Name}}</td>
<td>{{bet.GoldenBootPlayer.Name}}</td>
</tr>
</tbody>
</table>
Expand Down
Loading

0 comments on commit 74f6198

Please sign in to comment.