2015-04-27 12:40:57 -05:00
|
|
|
|
using System;
|
2021-08-29 13:10:10 -05:00
|
|
|
|
using SharedLibraryCore.Dtos;
|
2015-04-27 12:40:57 -05:00
|
|
|
|
|
2018-04-08 01:44:42 -05:00
|
|
|
|
namespace SharedLibraryCore.Helpers
|
2015-04-27 12:40:57 -05:00
|
|
|
|
{
|
2015-08-22 01:04:30 -05:00
|
|
|
|
public class PlayerHistory
|
2015-04-27 12:40:57 -05:00
|
|
|
|
{
|
2017-11-02 11:49:45 -05:00
|
|
|
|
// how many minutes between updates
|
|
|
|
|
public static readonly int UpdateInterval = 5;
|
|
|
|
|
|
2022-01-26 10:32:16 -06:00
|
|
|
|
private readonly DateTime When;
|
|
|
|
|
|
2017-09-27 15:07:43 -05:00
|
|
|
|
public PlayerHistory(int cNum)
|
2015-04-27 12:40:57 -05:00
|
|
|
|
{
|
2022-01-26 10:32:16 -06:00
|
|
|
|
var t = DateTime.UtcNow;
|
|
|
|
|
When = new DateTime(t.Year, t.Month, t.Day, t.Hour,
|
|
|
|
|
Math.Min(59, UpdateInterval * (int)Math.Round(t.Minute / (float)UpdateInterval)), 0);
|
2019-04-06 21:48:49 -05:00
|
|
|
|
y = cNum;
|
2017-09-27 15:07:43 -05:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2022-01-26 10:32:16 -06:00
|
|
|
|
/// Used by CanvasJS as a point on the x axis
|
2017-09-27 15:07:43 -05:00
|
|
|
|
/// </summary>
|
2022-01-26 10:32:16 -06:00
|
|
|
|
public string x => When.ToString("yyyy-MM-ddTHH:mm:ssZ");
|
2017-09-27 15:07:43 -05:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
2022-01-26 10:32:16 -06:00
|
|
|
|
/// Used by CanvasJS as a point on the y axis
|
2017-09-27 15:07:43 -05:00
|
|
|
|
/// </summary>
|
2019-04-06 21:48:49 -05:00
|
|
|
|
public int y { get; }
|
2021-08-29 13:10:10 -05:00
|
|
|
|
|
|
|
|
|
public ClientCountSnapshot ToClientCountSnapshot()
|
|
|
|
|
{
|
|
|
|
|
return new ClientCountSnapshot
|
|
|
|
|
{
|
|
|
|
|
ClientCount = y,
|
|
|
|
|
Time = When
|
|
|
|
|
};
|
|
|
|
|
}
|
2015-04-27 12:40:57 -05:00
|
|
|
|
}
|
2022-01-26 10:32:16 -06:00
|
|
|
|
}
|