|
|
|
@ -2,6 +2,7 @@
|
|
|
|
using System.Text.Json;
|
|
|
|
using System.Text.Json;
|
|
|
|
using Expedience.Api.Encryption;
|
|
|
|
using Expedience.Api.Encryption;
|
|
|
|
using Expedience.Infrastructure;
|
|
|
|
using Expedience.Infrastructure;
|
|
|
|
|
|
|
|
using Expedience.Infrastructure.Models;
|
|
|
|
using MassTransit;
|
|
|
|
using MassTransit;
|
|
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
using Microsoft.EntityFrameworkCore;
|
|
|
|
using Microsoft.EntityFrameworkCore;
|
|
|
|
@ -110,5 +111,52 @@ namespace Expedience.Api.Controllers
|
|
|
|
|
|
|
|
|
|
|
|
return StatusCode(500);
|
|
|
|
return StatusCode(500);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[HttpGet("TopX/{recordType}/{territoryId}/{limit}")]
|
|
|
|
|
|
|
|
public async Task<ActionResult> GetTopXRecords(int recordType, int territoryId, int limit, CancellationToken cancellationToken)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
try
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
using var scope = _serviceScopeFactory.CreateScope();
|
|
|
|
|
|
|
|
var repository = scope.ServiceProvider.GetService<IExpedienceRepository>();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var records = await repository.GetTopXRecords(recordType, territoryId, limit, cancellationToken);
|
|
|
|
|
|
|
|
var results = new List<DutyCompletionResult>();
|
|
|
|
|
|
|
|
foreach (var record in records)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
var dutyCompletionResult = new DutyCompletionResult
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
Id = record.Id,
|
|
|
|
|
|
|
|
UserId = record.UserId,
|
|
|
|
|
|
|
|
TerritoryId = record.TerritoryId,
|
|
|
|
|
|
|
|
IsMinILevel = recordType == 3,
|
|
|
|
|
|
|
|
HasNpcMembers = recordType == 4,
|
|
|
|
|
|
|
|
StartTime = record.StartTime,
|
|
|
|
|
|
|
|
EndTime = record.EndTime,
|
|
|
|
|
|
|
|
Hours = record.Duration.Hours,
|
|
|
|
|
|
|
|
Minutes = record.Duration.Minutes,
|
|
|
|
|
|
|
|
Seconds = record.Duration.Seconds,
|
|
|
|
|
|
|
|
Milliseconds = record.Duration.Milliseconds,
|
|
|
|
|
|
|
|
GameVersion = record.GameVersion,
|
|
|
|
|
|
|
|
PluginVersion = record.PluginVersion,
|
|
|
|
|
|
|
|
Territory = record.Territory,
|
|
|
|
|
|
|
|
User = record.User,
|
|
|
|
|
|
|
|
DataCenter = record.DutyCompletionResult.DataCenter,
|
|
|
|
|
|
|
|
UploadedAt = record.UploadedAt,
|
|
|
|
|
|
|
|
Lang = record.DutyCompletionResult.Lang,
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
results.Add(dutyCompletionResult);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return Ok(results);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
_logger.LogError(ex, "Error getting Top X Records: {errorMessage}", ex.Message);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return StatusCode(500);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|