Skip to content

Commit

Permalink
Fix ranking
Browse files Browse the repository at this point in the history
  • Loading branch information
BigBang1112 committed May 21, 2024
1 parent 8dd1ada commit 14dae22
Showing 1 changed file with 19 additions and 15 deletions.
34 changes: 19 additions & 15 deletions TMTurboRecords/TMTurboRecords/Services/RecordService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -91,12 +91,12 @@ public async Task<RecordsResponse> GetRecordsAsync(Platform platform, string map

if (prevTime is not null && rec.Time == prevTime)
{
rankOffset++;
rankOffset += rec.Count;
}
else
{
rank += rankOffset;
rankOffset = 1;
rankOffset = rec.Count;
}

prevTime = rec.Time;
Expand Down Expand Up @@ -229,22 +229,26 @@ private async Task<RecordsXmlResponse> GetRecordsAsync(Platform platformEnum, st
? DateTimeOffset.FromUnixTimeSeconds(dateLong)
: default(DateTimeOffset?);

var recs = contentElement.Elements("i")
.Select((element, index) =>
var recs = new List<Record>();

var rank = 1;

foreach (var element in contentElement.Elements("i"))
{
var timeMs = (int)uint.Parse(element.Element("s")?.Value ?? "0");

var record = new Record
{
var timeMs = (int)uint.Parse(element.Element("s")?.Value ?? "0");
PlatformRank = rank,
Time = timeMs == -1 ? null : new(timeMs),
Count = int.Parse(element.Element("c")?.Value ?? "0"),
Platform = platformEnum
};

var record = new Record
{
PlatformRank = index + 1,
Time = timeMs == -1 ? null : new(timeMs),
Count = int.Parse(element.Element("c")?.Value ?? "0"),
Platform = platformEnum
};
rank += record.Count;

return record;
})
.ToList();
recs.Add(record);
}

return new RecordsXmlResponse(date, recs, null);
}
Expand Down

0 comments on commit 14dae22

Please sign in to comment.