Skip to content

Commit

Permalink
impl #55
Browse files Browse the repository at this point in the history
  • Loading branch information
Lightczx committed Nov 19, 2024
1 parent d266cbe commit 8efd15d
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -88,13 +88,9 @@ public async Task<IActionResult> Upload([FromBody] SimpleRoleCombatRecord record
}

[HttpGet("Statistics")]
public IActionResult GetStatistics([FromQuery(Name = "Last")] bool last = false)
public IActionResult GetStatistics()
{
int scheduleId = RoleCombatScheduleId.GetForNow();
if (last)
{
scheduleId--;
}

string key = $"RoleCombatStatistics:{scheduleId}";
if (memoryCache.TryGetValue(key, out RoleCombatStatisticsItem? data))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@ namespace Snap.Hutao.Server.Model.RoleCombat;

public sealed class RoleCombatStatisticsItem
{
public int ScheduleId { get; set; }

public int RecordTotal { get; set; }

public long Timestamp { get; set; }

public List<ItemRate<uint, double>> BackupAvatarRates { get; set; } = default!;
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@ public async Task RunAsync()
int total = await Task.Run(() => RunCore(resultMap)).ConfigureAwait(false);
RoleCombatStatisticsItem item = new()
{
ScheduleId = RoleCombatScheduleId.GetForNow(),
RecordTotal = total,
Timestamp = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(),
BackupAvatarRates = resultMap.Select(kvp => new Model.Legacy.ItemRate<uint, double>(kvp.Key, kvp.Value / (double)total)).ToList(),
};

Expand Down

0 comments on commit 8efd15d

Please sign in to comment.