1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-28 09:43:10 +08:00

Implement dates with zero count fill

This commit is contained in:
Andrei Zavatski 2020-11-14 19:17:01 +03:00
parent af174aa653
commit 02168c6c2f
2 changed files with 28 additions and 2 deletions

View File

@ -1,6 +1,7 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. // Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text. // See the LICENCE file in the repository root for full licence text.
using System.Collections.Generic;
using osu.Framework.Bindables; using osu.Framework.Bindables;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
@ -38,7 +39,32 @@ namespace osu.Game.Overlays.Profile.Sections.Historical
if (values?.Length > 1) if (values?.Length > 1)
{ {
chart.Values = values; // Fill dates with 0 count
var newValues = new List<UserHistoryCount> { values[0] };
var newLast = values[0];
for (int i = 1; i < values.Length; i++)
{
while (hasMissingDates(newLast, values[i]))
{
newValues.Add(newLast = new UserHistoryCount
{
Count = 0,
Date = newLast.Date.AddMonths(1)
});
}
newValues.Add(newLast = values[i]);
}
static bool hasMissingDates(UserHistoryCount prev, UserHistoryCount current)
{
var possibleCurrent = prev.Date.AddMonths(1);
return possibleCurrent != current.Date;
}
chart.Values = newValues.ToArray();
Show(); Show();
return; return;
} }

View File

@ -19,7 +19,7 @@ namespace osu.Game.Overlays.Profile.Sections.Historical
{ {
private UserHistoryCount[] values; private UserHistoryCount[] values;
[CanBeNull] [NotNull]
public UserHistoryCount[] Values public UserHistoryCount[] Values
{ {
get => values; get => values;