BotSharp/src/Infrastructure/BotSharp.Abstraction/Statistics/Models/BotSharpStats.cs

48 lines
1.2 KiB
C#
Raw Normal View History

2025-01-28 22:46:59 +00:00
using BotSharp.Abstraction.Statistics.Enums;
2025-01-24 05:45:43 +00:00
namespace BotSharp.Abstraction.Statistics.Models;
public class BotSharpStats
{
2025-01-28 16:56:45 +00:00
[JsonPropertyName("metric")]
public string Metric { get; set; } = null!;
2025-01-24 05:45:43 +00:00
2025-01-28 16:56:45 +00:00
[JsonPropertyName("dimension")]
public string Dimension { get; set; } = null!;
2025-01-24 05:45:43 +00:00
[JsonPropertyName("data")]
2025-01-28 05:10:37 +00:00
public IDictionary<string, double> Data { get; set; } = new Dictionary<string, double>();
2025-01-24 05:45:43 +00:00
2025-01-24 19:42:17 +00:00
[JsonPropertyName("record_time")]
2025-01-28 22:46:59 +00:00
public DateTime RecordTime { get; set; } = DateTime.UtcNow;
[JsonIgnore]
public StatsInterval IntervalType { get; set; }
[JsonPropertyName("interval")]
public string Interval
2025-01-24 05:45:43 +00:00
{
get
{
2025-01-28 22:46:59 +00:00
return IntervalType.ToString();
}
2025-01-24 05:45:43 +00:00
set
{
2025-01-28 22:46:59 +00:00
if (Enum.TryParse(value, out StatsInterval type))
{
IntervalType = type;
}
2025-01-24 05:45:43 +00:00
}
}
2025-01-28 22:46:59 +00:00
[JsonPropertyName("start_time")]
public DateTime StartTime { get; set; }
[JsonPropertyName("end_time")]
public DateTime EndTime { get; set; }
2025-01-24 05:45:43 +00:00
public override string ToString()
{
2025-01-28 22:46:59 +00:00
return $"{Metric}-{Dimension} ({Interval}): {Data?.Count ?? 0}";
2025-01-24 05:45:43 +00:00
}
}