remove old endpoints

This commit is contained in:
Tomasi - Developing 2025-02-06 10:56:36 +01:00
parent db67a2b2d8
commit 0607c20106
3 changed files with 0 additions and 148 deletions

View File

@ -100,52 +100,6 @@ namespace Api.Controllers.v1
}
}
[AllowAnonymous]
[HttpGet("[action]/{allianceId:guid}")]
public async Task<ActionResult<List<PlayerMvpDto>>> 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<ActionResult<List<PlayerMvpDto>>> 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(

View File

@ -12,10 +12,6 @@ public interface IPlayerRepository
Task<Result<PagedResponseDto<PlayerDto>>> GetAllianceDismissPlayersAsync(Guid allianceId, int pageNumber, int pageSize, CancellationToken cancellationToken);
Task<Result<List<PlayerMvpDto>>> GetAlliancePlayersMvp(Guid allianceId, CancellationToken cancellationToken);
Task<Result<List<PlayerMvpDto>>> GetAllianceLeadershipMvp(Guid allianceId, CancellationToken cancellationToken);
Task<Result<List<PlayerMvpDto>>> GetAllianceMvp(Guid allianceId, string? playerType, CancellationToken cancellationToken);
Task<Result<DismissPlayerInformationDto>> GetDismissPlayerInformationAsync(Guid playerId, CancellationToken cancellationToken);

View File

@ -124,104 +124,6 @@ public class PlayerRepository(ApplicationContext context, IMapper mapper, ILogge
return playerMvps;
}
public async Task<Result<List<PlayerMvpDto>>> 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<Result<List<PlayerMvpDto>>> 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<Result<DismissPlayerInformationDto>> GetDismissPlayerInformationAsync(Guid playerId, CancellationToken cancellationToken)
{
var dismissPlayerInformation = await context.Players