mirror of
https://github.com/TomasiDeveloping/PlayerManagement.git
synced 2026-04-16 09:12:20 +00:00
remove old endpoints
This commit is contained in:
parent
db67a2b2d8
commit
0607c20106
@ -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(
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user