2021-10-15 10:27:38 +00:00
|
|
|
using Dapper;
|
|
|
|
|
2021-11-27 02:10:56 +00:00
|
|
|
namespace PluralKit.Core;
|
2021-10-15 10:27:38 +00:00
|
|
|
|
2021-11-27 02:10:56 +00:00
|
|
|
public partial class ModelRepository
|
2021-10-15 10:27:38 +00:00
|
|
|
{
|
2021-11-27 02:10:56 +00:00
|
|
|
public async Task UpdateStats()
|
2021-10-15 10:27:38 +00:00
|
|
|
{
|
2021-11-27 02:10:56 +00:00
|
|
|
await _db.Execute(conn =>
|
|
|
|
conn.ExecuteAsync("update info set system_count = (select count(*) from systems)"));
|
|
|
|
await _db.Execute(conn =>
|
|
|
|
conn.ExecuteAsync("update info set member_count = (select count(*) from members)"));
|
|
|
|
await _db.Execute(conn =>
|
|
|
|
conn.ExecuteAsync("update info set group_count = (select count(*) from groups)"));
|
|
|
|
await _db.Execute(conn =>
|
|
|
|
conn.ExecuteAsync("update info set switch_count = (select count(*) from switches)"));
|
|
|
|
await _db.Execute(conn =>
|
|
|
|
conn.ExecuteAsync("update info set message_count = (select count(*) from messages)"));
|
|
|
|
}
|
2021-10-15 10:27:38 +00:00
|
|
|
|
2021-11-27 02:10:56 +00:00
|
|
|
public Task<Counts> GetStats()
|
|
|
|
=> _db.Execute(conn => conn.QuerySingleAsync<Counts>("select * from info"));
|
2021-10-15 10:27:38 +00:00
|
|
|
|
2021-11-27 02:10:56 +00:00
|
|
|
public class Counts
|
|
|
|
{
|
|
|
|
public int SystemCount { get; }
|
|
|
|
public int MemberCount { get; }
|
|
|
|
public int GroupCount { get; }
|
|
|
|
public int SwitchCount { get; }
|
|
|
|
public int MessageCount { get; }
|
2021-10-15 10:27:38 +00:00
|
|
|
}
|
|
|
|
}
|