33 lines
1.1 KiB
C#
33 lines
1.1 KiB
C#
namespace decePubClient.Models.Mastodon;
|
|||
|
|
|
||
|
|
/// <summary>A hashtag as PrivaPub describes it: its last week of use in public posts it holds, and whether the persona
|
||
|
|
/// follows it (null when nobody is signed in).</summary>
|
||
|
|
public class Tag
|
||
|
|
{
|
||
|
|
public string Name { get; set; }
|
||
|
|
public string Url { get; set; }
|
||
|
|
public List<TagDay> History { get; set; } = [];
|
||
|
|
public bool? Following { get; set; }
|
||
|
|
|
||
|
|
public int WeekUses => History.Sum(h => h.UsesCount);
|
||
|
|
public int TodayAccounts => History.FirstOrDefault()?.AccountsCount ?? 0;
|
||
|
|
}
|
||
|
|
|
||
|
|
/// <summary>One day of a tag's or a link's use; Mastodon sends the numbers as strings, the day as unix time.</summary>
|
||
|
|
public class TagDay
|
||
|
|
{
|
||
|
|
public string Day { get; set; }
|
||
|
|
public string Uses { get; set; }
|
||
|
|
public string Accounts { get; set; }
|
||
|
|
|
||
|
|
public int UsesCount => int.TryParse(Uses, out var n) ? n : 0;
|
||
|
|
public int AccountsCount => int.TryParse(Accounts, out var n) ? n : 0;
|
||
|
|
}
|
||
|
|
|
||
|
|
/// <summary>A link many authors shared this week: its preview card with its days.</summary>
|
||
|
|
public class TrendLink : PreviewCard
|
||
|
|
{
|
||
|
|
public List<TagDay> History { get; set; } = [];
|
||
|
|
|
||
|
|
public int WeekAccounts => History.Sum(h => h.AccountsCount);
|
||
|
|
}
|