1
0
mirror of synced 2024-12-18 01:15:55 +01:00

Add clear,fc,pfc count

This commit is contained in:
asesidaa 2022-09-19 01:33:59 +08:00
parent fdbeb3b4bb
commit 752d5d9f8a
2 changed files with 13 additions and 4 deletions

View File

@ -15,6 +15,9 @@ public class SongBestData
public Difficulty Difficulty { get; set; }
public int PlayCount { get; set; }
public int ClearCount { get; set; }
public int FullComboCount { get; set; }
public int PerfectCount { get; set; }
public uint BestScore { get; set; }

View File

@ -1,4 +1,5 @@
using SharedProject.Models.Responses;
using System.Collections.Immutable;
using SharedProject.Models.Responses;
namespace TaikoLocalServer.Controllers.Api;
@ -30,11 +31,16 @@ public class PlayDataController : BaseController<PlayDataController>
}
var songBestRecords = await songBestDatumService.GetAllSongBestAsModel(baid);
var songPlayLogs = await songPlayDatumService.GetSongPlayDatumByBaid(baid);
var playLogs = await songPlayDatumService.GetSongPlayDatumByBaid(baid);
foreach (var songBestData in songBestRecords)
{
songBestData.PlayCount = songPlayLogs.Count(datum => datum.SongId == songBestData.SongId &&
datum.Difficulty == songBestData.Difficulty);
var songPlayLogs = playLogs.Where(datum => datum.SongId == songBestData.SongId &&
datum.Difficulty == songBestData.Difficulty).ToList();
songBestData.PlayCount = songPlayLogs.Count;
var groups = songPlayLogs.GroupBy(datum => datum.Crown).ToLookup(datums => datums.Key);
songBestData.ClearCount = groups[CrownType.Clear].Count();
songBestData.FullComboCount = groups[CrownType.Gold].Count();
songBestData.PerfectCount = groups[CrownType.Dondaful].Count();
}
var favoriteSongs = await userDatumService.GetFavoriteSongIds(baid);
var favoriteSet = favoriteSongs.ToHashSet();