From 0607c20106773222f1f13985ebb853075c943be9 Mon Sep 17 00:00:00 2001 From: Tomasi - Developing Date: Thu, 6 Feb 2025 10:56:36 +0100 Subject: [PATCH] remove old endpoints --- Api/Controllers/v1/PlayersController.cs | 46 --------- Application/Interfaces/IPlayerRepository.cs | 4 - Application/Repositories/PlayerRepository.cs | 98 -------------------- 3 files changed, 148 deletions(-) diff --git a/Api/Controllers/v1/PlayersController.cs b/Api/Controllers/v1/PlayersController.cs index 55ddd4f..9653420 100644 --- a/Api/Controllers/v1/PlayersController.cs +++ b/Api/Controllers/v1/PlayersController.cs @@ -100,52 +100,6 @@ namespace Api.Controllers.v1 } } - [AllowAnonymous] - [HttpGet("[action]/{allianceId:guid}")] - public async Task>> GetAllianceMvpPlayers(Guid allianceId, - CancellationToken cancellationToken) - { - try - { - var alliancePlayersResult = - await playerRepository.GetAlliancePlayersMvp(allianceId, cancellationToken); - - if (alliancePlayersResult.IsFailure) return BadRequest(alliancePlayersResult.Error); - - return alliancePlayersResult.Value.Count > 0 - ? Ok(alliancePlayersResult.Value) - : NoContent(); - } - catch (Exception e) - { - logger.LogError(e, e.Message); - return StatusCode(StatusCodes.Status500InternalServerError); - } - } - - [AllowAnonymous] - [HttpGet("[action]/{allianceId:guid}")] - public async Task>> GetAllianceLeadershipMvp(Guid allianceId, - CancellationToken cancellationToken) - { - try - { - var alliancePlayersResult = - await playerRepository.GetAllianceLeadershipMvp(allianceId, cancellationToken); - - if (alliancePlayersResult.IsFailure) return BadRequest(alliancePlayersResult.Error); - - return alliancePlayersResult.Value.Count > 0 - ? Ok(alliancePlayersResult.Value) - : NoContent(); - } - catch (Exception e) - { - logger.LogError(e, e.Message); - return StatusCode(StatusCodes.Status500InternalServerError); - } - } - [AllowApiKey] [HttpGet("Mvp/")] [SwaggerOperation( diff --git a/Application/Interfaces/IPlayerRepository.cs b/Application/Interfaces/IPlayerRepository.cs index 36ed4c3..a0d6a54 100644 --- a/Application/Interfaces/IPlayerRepository.cs +++ b/Application/Interfaces/IPlayerRepository.cs @@ -12,10 +12,6 @@ public interface IPlayerRepository Task>> GetAllianceDismissPlayersAsync(Guid allianceId, int pageNumber, int pageSize, CancellationToken cancellationToken); - Task>> GetAlliancePlayersMvp(Guid allianceId, CancellationToken cancellationToken); - - Task>> GetAllianceLeadershipMvp(Guid allianceId, CancellationToken cancellationToken); - Task>> GetAllianceMvp(Guid allianceId, string? playerType, CancellationToken cancellationToken); Task> GetDismissPlayerInformationAsync(Guid playerId, CancellationToken cancellationToken); diff --git a/Application/Repositories/PlayerRepository.cs b/Application/Repositories/PlayerRepository.cs index b1dce3a..03e1c93 100644 --- a/Application/Repositories/PlayerRepository.cs +++ b/Application/Repositories/PlayerRepository.cs @@ -124,104 +124,6 @@ public class PlayerRepository(ApplicationContext context, IMapper mapper, ILogge return playerMvps; } - public async Task>> GetAlliancePlayersMvp(Guid allianceId, CancellationToken cancellationToken) - { - var currentDate = DateTime.Now; - var threeWeeksAgo = currentDate.AddDays(-21); - - var playerMvps = await context.Players - .Where(p => p.AllianceId == allianceId && p.Rank.Name != "R4" && p.Rank.Name != "R5") - .Select(p => new - { - p.Id, - p.PlayerName, - Rank = p.Rank.Name, - - VsDuels = context.VsDuelParticipants - .Where(vp => vp.PlayerId == p.Id && vp.VsDuel.EventDate <= currentDate && !vp.VsDuel.IsInProgress) - .OrderByDescending(vp => vp.VsDuel.EventDate) - .Take(3) - .Sum(vp => vp.WeeklyPoints), - - IsOldestVsDuelParticipated = context.VsDuelParticipants - .Where(vp => vp.PlayerId == p.Id && vp.VsDuel.EventDate <= currentDate && !vp.VsDuel.IsInProgress) - .OrderByDescending(vp => vp.VsDuel.EventDate) - .Skip(2) - .Take(1) - .Any(), - - MarshalGuardParticipationCount = context.MarshalGuardParticipants - .Count(mpg => mpg.PlayerId == p.Id && mpg.Participated && mpg.MarshalGuard.EventDate > threeWeeksAgo), - - DessertStormParticipationCount = context.DesertStormParticipants - .Count(dsp => dsp.PlayerId == p.Id && dsp.Participated && dsp.DesertStorm.EventDate > threeWeeksAgo) - }) - .Select(p => new PlayerMvpDto() - { - Name = p.PlayerName, - AllianceRank = p.Rank, - DuelPointsLast3Weeks = p.VsDuels, - MarshalParticipationCount = p.MarshalGuardParticipationCount, - DesertStormParticipationCount = p.DessertStormParticipationCount, - HasParticipatedInOldestDuel = p.IsOldestVsDuelParticipated, - MvpScore = Math.Round( - (decimal)((p.VsDuels / 1000000.0 * 0.8) + - ((p.MarshalGuardParticipationCount * 20 + p.DessertStormParticipationCount * 40) * 0.2)),2) - }) - .OrderByDescending(p => p.MvpScore) - .ThenByDescending(p => p.DuelPointsLast3Weeks) - .ThenByDescending(p => p.MarshalParticipationCount) - .ThenBy(p => p.Name) - .ToListAsync(cancellationToken); - - return playerMvps; - } - - public async Task>> GetAllianceLeadershipMvp(Guid allianceId, CancellationToken cancellationToken) - { - var currentDate = DateTime.Now; - var threeWeeksAgo = currentDate.AddDays(-21); - - var playerMvps = await context.Players - .Where(p => p.AllianceId == allianceId && (p.Rank.Name == "R4" || p.Rank.Name == "R5")) - .Select(p => new - { - p.Id, - p.PlayerName, - Rank = p.Rank.Name, - - VsDuels = context.VsDuelParticipants - .Where(vp => vp.PlayerId == p.Id && vp.VsDuel.EventDate <= currentDate && !vp.VsDuel.IsInProgress) - .OrderByDescending(vp => vp.VsDuel.EventDate) - .Take(3) - .Sum(vp => vp.WeeklyPoints), - - MarshalGuardParticipationCount = context.MarshalGuardParticipants - .Count(mpg => mpg.PlayerId == p.Id && mpg.Participated && mpg.MarshalGuard.EventDate > threeWeeksAgo), - - DessertStormParticipationCount = context.DesertStormParticipants - .Count(dsp => dsp.PlayerId == p.Id && dsp.Participated && dsp.DesertStorm.EventDate > threeWeeksAgo) - }) - .Select(p => new PlayerMvpDto() - { - Name = p.PlayerName, - AllianceRank = p.Rank, - DuelPointsLast3Weeks = p.VsDuels, - MarshalParticipationCount = p.MarshalGuardParticipationCount, - DesertStormParticipationCount = p.DessertStormParticipationCount, - MvpScore = Math.Round( - (decimal)((p.VsDuels / 1000000.0 * 0.8) + - ((p.MarshalGuardParticipationCount * 20 + p.DessertStormParticipationCount * 40) * 0.2)), 2) - }) - .OrderByDescending(p => p.MvpScore) - .ThenByDescending(p => p.DuelPointsLast3Weeks) - .ThenByDescending(p => p.MarshalParticipationCount) - .ThenBy(p => p.Name) - .ToListAsync(cancellationToken); - - return playerMvps; - } - public async Task> GetDismissPlayerInformationAsync(Guid playerId, CancellationToken cancellationToken) { var dismissPlayerInformation = await context.Players