Optimized .waifuinfo

This commit is contained in:
Kwoth
2022-11-15 22:45:00 +01:00
parent 9ce2837f5a
commit 8a6edc17e4
5 changed files with 46 additions and 46 deletions

View File

@@ -10,6 +10,7 @@ namespace NadekoBot.Db;
public class WaifuInfoStats
{
public int WaifuId { get; init; }
public string FullName { get; init; }
public long Price { get; init; }
public string ClaimerName { get; init; }
@@ -17,9 +18,6 @@ public class WaifuInfoStats
public int AffinityCount { get; init; }
public int DivorceCount { get; init; }
public int ClaimCount { get; init; }
public List<WaifuItem> Items { get; init; }
public List<int> Claims { get; init; }
public List<int> Fans { get; init; }
}
public static class WaifuExtensions
@@ -103,6 +101,7 @@ public static class WaifuExtensions
.FirstOrDefault())
.Select(w => new WaifuInfoStats
{
WaifuId = w.WaifuId,
FullName =
ctx.Set<DiscordUser>()
.AsQueryable()
@@ -134,20 +133,7 @@ public static class WaifuExtensions
.Count(x => x.OldId == w.WaifuId
&& x.NewId == null
&& x.UpdateType == WaifuUpdateType.Claimed),
Price = w.Price,
Claims = ctx.WaifuInfo
.Where(x => x.ClaimerId == w.WaifuId)
.Select(x => x.WaifuId)
.ToList(),
Fans = ctx.WaifuInfo
.Where(x => x.AffinityId == w.WaifuId)
.Select(x => x.WaifuId)
.ToList(),
Items = w.Items
})
.FirstOrDefault();

View File

@@ -7,7 +7,7 @@ public class WaifuInfo : DbEntity
{
public int WaifuId { get; set; }
public DiscordUser Waifu { get; set; }
public int? ClaimerId { get; set; }
public DiscordUser Claimer { get; set; }

View File

@@ -7,4 +7,4 @@ public class WaifuItem : DbEntity
public int? WaifuInfoId { get; set; }
public string ItemEmoji { get; set; }
public string Name { get; set; }
}
}