mirror of
https://gitlab.com/Kwoth/nadekobot.git
synced 2025-09-10 17:28:27 -04:00
Removed waifu repository
This commit is contained in:
@@ -138,7 +138,7 @@ WHERE CurrencyAmount > {config.Decay.MinThreshold} AND UserId!={_client.CurrentU
|
|||||||
cash = uow.DiscordUsers.GetTotalCurrency();
|
cash = uow.DiscordUsers.GetTotalCurrency();
|
||||||
onePercent = uow.DiscordUsers.GetTopOnePercentCurrency(_client.CurrentUser.Id);
|
onePercent = uow.DiscordUsers.GetTopOnePercentCurrency(_client.CurrentUser.Id);
|
||||||
planted = uow._context.PlantedCurrency.AsQueryable().Sum(x => x.Amount);
|
planted = uow._context.PlantedCurrency.AsQueryable().Sum(x => x.Amount);
|
||||||
waifus = uow.Waifus.GetTotalValue();
|
waifus = uow._context.WaifuInfo.GetTotalValue();
|
||||||
bot = uow.DiscordUsers.GetUserCurrency(_client.CurrentUser.Id);
|
bot = uow.DiscordUsers.GetUserCurrency(_client.CurrentUser.Id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -46,7 +46,7 @@ namespace NadekoBot.Modules.Gambling.Services
|
|||||||
|
|
||||||
using (var uow = _db.GetDbContext())
|
using (var uow = _db.GetDbContext())
|
||||||
{
|
{
|
||||||
var waifu = uow.Waifus.ByWaifuUserId(waifuId);
|
var waifu = uow._context.WaifuInfo.ByWaifuUserId(waifuId);
|
||||||
var ownerUser = uow.DiscordUsers.GetOrCreate(owner);
|
var ownerUser = uow.DiscordUsers.GetOrCreate(owner);
|
||||||
|
|
||||||
// owner has to be the owner of the waifu
|
// owner has to be the owner of the waifu
|
||||||
@@ -96,7 +96,7 @@ namespace NadekoBot.Modules.Gambling.Services
|
|||||||
var settings = _gss.Data;
|
var settings = _gss.Data;
|
||||||
using (var uow = _db.GetDbContext())
|
using (var uow = _db.GetDbContext())
|
||||||
{
|
{
|
||||||
var waifu = uow.Waifus.ByWaifuUserId(user.Id);
|
var waifu = uow._context.WaifuInfo.ByWaifuUserId(user.Id);
|
||||||
|
|
||||||
if (waifu == null)
|
if (waifu == null)
|
||||||
return settings.Waifu.MinPrice;
|
return settings.Waifu.MinPrice;
|
||||||
@@ -143,7 +143,7 @@ namespace NadekoBot.Modules.Gambling.Services
|
|||||||
uow._context.WaifuUpdates.RemoveRange(affs);
|
uow._context.WaifuUpdates.RemoveRange(affs);
|
||||||
//reset divorces to 0
|
//reset divorces to 0
|
||||||
uow._context.WaifuUpdates.RemoveRange(divorces);
|
uow._context.WaifuUpdates.RemoveRange(divorces);
|
||||||
var waifu = uow.Waifus.ByWaifuUserId(user.Id);
|
var waifu = uow._context.WaifuInfo.ByWaifuUserId(user.Id);
|
||||||
//reset price, remove items
|
//reset price, remove items
|
||||||
//remove owner, remove affinity
|
//remove owner, remove affinity
|
||||||
waifu.Price = 50;
|
waifu.Price = 50;
|
||||||
@@ -167,7 +167,7 @@ namespace NadekoBot.Modules.Gambling.Services
|
|||||||
bool isAffinity;
|
bool isAffinity;
|
||||||
using (var uow = _db.GetDbContext())
|
using (var uow = _db.GetDbContext())
|
||||||
{
|
{
|
||||||
w = uow.Waifus.ByWaifuUserId(target.Id);
|
w = uow._context.WaifuInfo.ByWaifuUserId(target.Id);
|
||||||
isAffinity = (w?.Affinity?.UserId == user.Id);
|
isAffinity = (w?.Affinity?.UserId == user.Id);
|
||||||
if (w == null)
|
if (w == null)
|
||||||
{
|
{
|
||||||
@@ -179,7 +179,7 @@ namespace NadekoBot.Modules.Gambling.Services
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
uow.Waifus.Add(w = new WaifuInfo()
|
uow._context.WaifuInfo.Add(w = new WaifuInfo()
|
||||||
{
|
{
|
||||||
Waifu = waifu,
|
Waifu = waifu,
|
||||||
Claimer = claimer,
|
Claimer = claimer,
|
||||||
@@ -257,7 +257,7 @@ namespace NadekoBot.Modules.Gambling.Services
|
|||||||
TimeSpan? remaining = null;
|
TimeSpan? remaining = null;
|
||||||
using (var uow = _db.GetDbContext())
|
using (var uow = _db.GetDbContext())
|
||||||
{
|
{
|
||||||
var w = uow.Waifus.ByWaifuUserId(user.Id);
|
var w = uow._context.WaifuInfo.ByWaifuUserId(user.Id);
|
||||||
var newAff = target == null ? null : uow.DiscordUsers.GetOrCreate(target);
|
var newAff = target == null ? null : uow.DiscordUsers.GetOrCreate(target);
|
||||||
if (w?.Affinity?.UserId == target?.Id)
|
if (w?.Affinity?.UserId == target?.Id)
|
||||||
{
|
{
|
||||||
@@ -268,7 +268,7 @@ namespace NadekoBot.Modules.Gambling.Services
|
|||||||
else if (w == null)
|
else if (w == null)
|
||||||
{
|
{
|
||||||
var thisUser = uow.DiscordUsers.GetOrCreate(user);
|
var thisUser = uow.DiscordUsers.GetOrCreate(user);
|
||||||
uow.Waifus.Add(new WaifuInfo()
|
uow._context.WaifuInfo.Add(new WaifuInfo()
|
||||||
{
|
{
|
||||||
Affinity = newAff,
|
Affinity = newAff,
|
||||||
Waifu = thisUser,
|
Waifu = thisUser,
|
||||||
@@ -311,14 +311,14 @@ namespace NadekoBot.Modules.Gambling.Services
|
|||||||
{
|
{
|
||||||
using (var uow = _db.GetDbContext())
|
using (var uow = _db.GetDbContext())
|
||||||
{
|
{
|
||||||
return uow.Waifus.GetTop(9, page * 9);
|
return uow._context.WaifuInfo.GetTop(9, page * 9);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public ulong GetWaifuUserId(ulong ownerId, string name)
|
public ulong GetWaifuUserId(ulong ownerId, string name)
|
||||||
{
|
{
|
||||||
using var uow = _db.GetDbContext();
|
using var uow = _db.GetDbContext();
|
||||||
return uow.Waifus.GetWaifuUserId(ownerId, name);
|
return uow._context.WaifuInfo.GetWaifuUserId(ownerId, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<(WaifuInfo, DivorceResult, long, TimeSpan?)> DivorceWaifuAsync(IUser user, ulong targetId)
|
public async Task<(WaifuInfo, DivorceResult, long, TimeSpan?)> DivorceWaifuAsync(IUser user, ulong targetId)
|
||||||
@@ -329,7 +329,7 @@ namespace NadekoBot.Modules.Gambling.Services
|
|||||||
WaifuInfo w = null;
|
WaifuInfo w = null;
|
||||||
using (var uow = _db.GetDbContext())
|
using (var uow = _db.GetDbContext())
|
||||||
{
|
{
|
||||||
w = uow.Waifus.ByWaifuUserId(targetId);
|
w = uow._context.WaifuInfo.ByWaifuUserId(targetId);
|
||||||
var now = DateTime.UtcNow;
|
var now = DateTime.UtcNow;
|
||||||
if (w?.Claimer == null || w.Claimer.UserId != user.Id)
|
if (w?.Claimer == null || w.Claimer.UserId != user.Id)
|
||||||
result = DivorceResult.NotYourWife;
|
result = DivorceResult.NotYourWife;
|
||||||
@@ -381,12 +381,12 @@ namespace NadekoBot.Modules.Gambling.Services
|
|||||||
|
|
||||||
using (var uow = _db.GetDbContext())
|
using (var uow = _db.GetDbContext())
|
||||||
{
|
{
|
||||||
var w = uow.Waifus.ByWaifuUserId(giftedWaifu.Id,
|
var w = uow._context.WaifuInfo.ByWaifuUserId(giftedWaifu.Id,
|
||||||
set => set.Include(x => x.Items)
|
set => set.Include(x => x.Items)
|
||||||
.Include(x => x.Claimer));
|
.Include(x => x.Claimer));
|
||||||
if (w == null)
|
if (w == null)
|
||||||
{
|
{
|
||||||
uow.Waifus.Add(w = new WaifuInfo()
|
uow._context.WaifuInfo.Add(w = new WaifuInfo()
|
||||||
{
|
{
|
||||||
Affinity = null,
|
Affinity = null,
|
||||||
Claimer = null,
|
Claimer = null,
|
||||||
@@ -420,7 +420,7 @@ namespace NadekoBot.Modules.Gambling.Services
|
|||||||
{
|
{
|
||||||
using (var uow = _db.GetDbContext())
|
using (var uow = _db.GetDbContext())
|
||||||
{
|
{
|
||||||
var wi = uow.Waifus.GetWaifuInfo(targetId);
|
var wi = uow._context.GetWaifuInfo(targetId);
|
||||||
if (wi is null)
|
if (wi is null)
|
||||||
{
|
{
|
||||||
wi = new WaifuInfoStats
|
wi = new WaifuInfoStats
|
||||||
|
@@ -7,7 +7,6 @@ namespace NadekoBot.Core.Services.Database
|
|||||||
public interface IUnitOfWork : IDisposable
|
public interface IUnitOfWork : IDisposable
|
||||||
{
|
{
|
||||||
NadekoContext _context { get; }
|
NadekoContext _context { get; }
|
||||||
IWaifuRepository Waifus { get; }
|
|
||||||
IDiscordUserRepository DiscordUsers { get; }
|
IDiscordUserRepository DiscordUsers { get; }
|
||||||
|
|
||||||
int SaveChanges();
|
int SaveChanges();
|
||||||
|
@@ -59,6 +59,7 @@ namespace NadekoBot.Core.Services.Database
|
|||||||
public DbSet<MusicPlayerSettings> MusicPlayerSettings { get; set; }
|
public DbSet<MusicPlayerSettings> MusicPlayerSettings { get; set; }
|
||||||
public DbSet<Repeater> Repeaters { get; set; }
|
public DbSet<Repeater> Repeaters { get; set; }
|
||||||
public DbSet<Poll> Poll { get; set; }
|
public DbSet<Poll> Poll { get; set; }
|
||||||
|
public DbSet<WaifuInfo> WaifuInfo { get; set; }
|
||||||
|
|
||||||
public NadekoContext(DbContextOptions<NadekoContext> options) : base(options)
|
public NadekoContext(DbContextOptions<NadekoContext> options) : base(options)
|
||||||
{
|
{
|
||||||
|
@@ -1,34 +0,0 @@
|
|||||||
using Microsoft.EntityFrameworkCore;
|
|
||||||
using NadekoBot.Core.Services.Database.Models;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using NadekoBot.Services.Database.Repositories;
|
|
||||||
|
|
||||||
namespace NadekoBot.Core.Services.Database.Repositories
|
|
||||||
{
|
|
||||||
public interface IWaifuRepository : IRepository<WaifuInfo>
|
|
||||||
{
|
|
||||||
IEnumerable<WaifuLbResult> GetTop(int count, int skip = 0);
|
|
||||||
WaifuInfo ByWaifuUserId(ulong userId, Func<DbSet<WaifuInfo>, IQueryable<WaifuInfo>> includes = null);
|
|
||||||
IEnumerable<string> GetWaifuNames(ulong userId);
|
|
||||||
decimal GetTotalValue();
|
|
||||||
int AffinityCount(ulong userId);
|
|
||||||
WaifuInfoStats GetWaifuInfo(ulong id);
|
|
||||||
public ulong GetWaifuUserId(ulong ownerId, string name);
|
|
||||||
}
|
|
||||||
|
|
||||||
public class WaifuInfoStats
|
|
||||||
{
|
|
||||||
public string FullName { get; set; }
|
|
||||||
public int Price { get; set; }
|
|
||||||
public string ClaimerName { get; set; }
|
|
||||||
public string AffinityName { get; set; }
|
|
||||||
public int AffinityCount { get; set; }
|
|
||||||
public int DivorceCount { get; set; }
|
|
||||||
public int ClaimCount { get; set; }
|
|
||||||
public List<WaifuItem> Items { get; set; }
|
|
||||||
public List<string> Claims { get; set; }
|
|
||||||
public List<string> Fans { get; set; }
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,69 +1,55 @@
|
|||||||
using Microsoft.EntityFrameworkCore;
|
|
||||||
using NadekoBot.Services.Database.Models;
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using NadekoBot.Core.Services.Database;
|
||||||
using NadekoBot.Core.Services.Database.Models;
|
using NadekoBot.Core.Services.Database.Models;
|
||||||
using NadekoBot.Core.Services.Database.Repositories;
|
using NadekoBot.Migrations;
|
||||||
|
using NadekoBot.Services.Database.Models;
|
||||||
|
|
||||||
namespace NadekoBot.Services.Database.Repositories.Impl
|
namespace NadekoBot.Modules.Gambling
|
||||||
{
|
{
|
||||||
public class WaifuRepository : Repository<WaifuInfo>, IWaifuRepository
|
public class WaifuInfoStats
|
||||||
{
|
|
||||||
public WaifuRepository(DbContext context) : base(context)
|
|
||||||
{
|
{
|
||||||
|
public string FullName { get; set; }
|
||||||
|
public int Price { get; set; }
|
||||||
|
public string ClaimerName { get; set; }
|
||||||
|
public string AffinityName { get; set; }
|
||||||
|
public int AffinityCount { get; set; }
|
||||||
|
public int DivorceCount { get; set; }
|
||||||
|
public int ClaimCount { get; set; }
|
||||||
|
public List<WaifuItem> Items { get; set; }
|
||||||
|
public List<string> Claims { get; set; }
|
||||||
|
public List<string> Fans { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public WaifuInfo ByWaifuUserId(ulong userId, Func<DbSet<WaifuInfo>, IQueryable<WaifuInfo>> includes = null)
|
public static class WaifuExtensions
|
||||||
|
{
|
||||||
|
public static WaifuInfo ByWaifuUserId(this DbSet<WaifuInfo> waifus, ulong userId, Func<DbSet<WaifuInfo>, IQueryable<WaifuInfo>> includes = null)
|
||||||
{
|
{
|
||||||
if (includes == null)
|
if (includes == null)
|
||||||
{
|
{
|
||||||
return _set.Include(wi => wi.Waifu)
|
return waifus.Include(wi => wi.Waifu)
|
||||||
.Include(wi => wi.Affinity)
|
.Include(wi => wi.Affinity)
|
||||||
.Include(wi => wi.Claimer)
|
.Include(wi => wi.Claimer)
|
||||||
.Include(wi => wi.Items)
|
.Include(wi => wi.Items)
|
||||||
.FirstOrDefault(wi => wi.WaifuId == _context.Set<DiscordUser>()
|
.FirstOrDefault(wi => wi.Waifu.UserId == userId);
|
||||||
.AsQueryable()
|
|
||||||
.Where(x => x.UserId == userId)
|
|
||||||
.Select(x => x.Id)
|
|
||||||
.FirstOrDefault());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return includes(_set)
|
return includes(waifus)
|
||||||
.AsQueryable()
|
.AsQueryable()
|
||||||
.FirstOrDefault(wi => wi.WaifuId == _context.Set<DiscordUser>()
|
.FirstOrDefault(wi => wi.Waifu.UserId == userId);
|
||||||
.AsQueryable()
|
|
||||||
.Where(x => x.UserId == userId)
|
|
||||||
.Select(x => x.Id)
|
|
||||||
.FirstOrDefault());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public IEnumerable<string> GetWaifuNames(ulong userId)
|
public static IEnumerable<WaifuLbResult> GetTop(this DbSet<WaifuInfo> waifus, int count, int skip = 0)
|
||||||
{
|
|
||||||
var waifus = _set.AsQueryable().Where(x => x.ClaimerId != null &&
|
|
||||||
x.ClaimerId == _context.Set<DiscordUser>()
|
|
||||||
.AsQueryable()
|
|
||||||
.Where(y => y.UserId == userId)
|
|
||||||
.Select(y => y.Id)
|
|
||||||
.FirstOrDefault())
|
|
||||||
.Select(x => x.WaifuId);
|
|
||||||
|
|
||||||
return _context.Set<DiscordUser>()
|
|
||||||
.AsQueryable()
|
|
||||||
.Where(x => waifus.Contains(x.Id))
|
|
||||||
.Select(x => x.Username + "#" + x.Discriminator)
|
|
||||||
.ToList();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public IEnumerable<WaifuLbResult> GetTop(int count, int skip = 0)
|
|
||||||
{
|
{
|
||||||
if (count < 0)
|
if (count < 0)
|
||||||
throw new ArgumentOutOfRangeException(nameof(count));
|
throw new ArgumentOutOfRangeException(nameof(count));
|
||||||
if (count == 0)
|
if (count == 0)
|
||||||
return new List<WaifuLbResult>();
|
return new List<WaifuLbResult>();
|
||||||
|
|
||||||
return _set.Include(wi => wi.Waifu)
|
return waifus.Include(wi => wi.Waifu)
|
||||||
.Include(wi => wi.Affinity)
|
.Include(wi => wi.Affinity)
|
||||||
.Include(wi => wi.Claimer)
|
.Include(wi => wi.Claimer)
|
||||||
.OrderByDescending(wi => wi.Price)
|
.OrderByDescending(wi => wi.Price)
|
||||||
@@ -83,22 +69,17 @@ namespace NadekoBot.Services.Database.Repositories.Impl
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public decimal GetTotalValue()
|
public static decimal GetTotalValue(this DbSet<WaifuInfo> waifus)
|
||||||
{
|
{
|
||||||
return _set
|
return waifus
|
||||||
.AsQueryable()
|
.AsQueryable()
|
||||||
.Where(x => x.ClaimerId != null)
|
.Where(x => x.ClaimerId != null)
|
||||||
.Sum(x => x.Price);
|
.Sum(x => x.Price);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int AffinityCount(ulong userId)
|
public static int AffinityCount(this DbSet<WaifuUpdate> updates, ulong userId)
|
||||||
{
|
{
|
||||||
//return _context.Set<WaifuUpdate>()
|
return updates
|
||||||
// .Count(w => w.User.UserId == userId &&
|
|
||||||
// w.UpdateType == WaifuUpdateType.AffinityChanged &&
|
|
||||||
// w.New != null));
|
|
||||||
|
|
||||||
return _context.Set<WaifuUpdate>()
|
|
||||||
.FromSqlInterpolated($@"SELECT 1
|
.FromSqlInterpolated($@"SELECT 1
|
||||||
FROM WaifuUpdates
|
FROM WaifuUpdates
|
||||||
WHERE UserId = (SELECT Id from DiscordUser WHERE UserId={userId}) AND
|
WHERE UserId = (SELECT Id from DiscordUser WHERE UserId={userId}) AND
|
||||||
@@ -107,9 +88,9 @@ WHERE UserId = (SELECT Id from DiscordUser WHERE UserId={userId}) AND
|
|||||||
.Count();
|
.Count();
|
||||||
}
|
}
|
||||||
|
|
||||||
public ulong GetWaifuUserId(ulong ownerId, string name)
|
public static ulong GetWaifuUserId(this DbSet<WaifuInfo> waifus, ulong ownerId, string name)
|
||||||
{
|
{
|
||||||
return _set
|
return waifus
|
||||||
.AsQueryable()
|
.AsQueryable()
|
||||||
.AsNoTracking()
|
.AsNoTracking()
|
||||||
.Where(x => x.Claimer.UserId == ownerId
|
.Where(x => x.Claimer.UserId == ownerId
|
||||||
@@ -118,48 +99,49 @@ WHERE UserId = (SELECT Id from DiscordUser WHERE UserId={userId}) AND
|
|||||||
.FirstOrDefault();
|
.FirstOrDefault();
|
||||||
}
|
}
|
||||||
|
|
||||||
public WaifuInfoStats GetWaifuInfo(ulong userId)
|
public static WaifuInfoStats GetWaifuInfo(this NadekoContext ctx, ulong userId)
|
||||||
{
|
{
|
||||||
_context.Database.ExecuteSqlInterpolated($@"
|
ctx.Database.ExecuteSqlInterpolated($@"
|
||||||
INSERT OR IGNORE INTO WaifuInfo (AffinityId, ClaimerId, Price, WaifuId)
|
INSERT OR IGNORE INTO WaifuInfo (AffinityId, ClaimerId, Price, WaifuId)
|
||||||
VALUES ({null}, {null}, {1}, (SELECT Id FROM DiscordUser WHERE UserId={userId}));");
|
VALUES ({null}, {null}, {1}, (SELECT Id FROM DiscordUser WHERE UserId={userId}));");
|
||||||
|
|
||||||
var toReturn = _set.AsQueryable()
|
var toReturn = ctx.WaifuInfo
|
||||||
.Where(w => w.WaifuId == _context.Set<DiscordUser>()
|
.AsQueryable()
|
||||||
|
.Where(w => w.WaifuId == ctx.Set<DiscordUser>()
|
||||||
.AsQueryable()
|
.AsQueryable()
|
||||||
.Where(u => u.UserId == userId)
|
.Where(u => u.UserId == userId)
|
||||||
.Select(u => u.Id).FirstOrDefault())
|
.Select(u => u.Id).FirstOrDefault())
|
||||||
.Select(w => new WaifuInfoStats
|
.Select(w => new WaifuInfoStats
|
||||||
{
|
{
|
||||||
FullName = _context.Set<DiscordUser>()
|
FullName = ctx.Set<DiscordUser>()
|
||||||
.AsQueryable()
|
.AsQueryable()
|
||||||
.Where(u => u.UserId == userId)
|
.Where(u => u.UserId == userId)
|
||||||
.Select(u => u.Username + "#" + u.Discriminator)
|
.Select(u => u.Username + "#" + u.Discriminator)
|
||||||
.FirstOrDefault(),
|
.FirstOrDefault(),
|
||||||
|
|
||||||
AffinityCount = _context.Set<WaifuUpdate>()
|
AffinityCount = ctx.Set<WaifuUpdate>()
|
||||||
.AsQueryable()
|
.AsQueryable()
|
||||||
.Count(x => x.UserId == w.WaifuId &&
|
.Count(x => x.UserId == w.WaifuId &&
|
||||||
x.UpdateType == WaifuUpdateType.AffinityChanged &&
|
x.UpdateType == WaifuUpdateType.AffinityChanged &&
|
||||||
x.NewId != null),
|
x.NewId != null),
|
||||||
|
|
||||||
AffinityName = _context.Set<DiscordUser>()
|
AffinityName = ctx.Set<DiscordUser>()
|
||||||
.AsQueryable()
|
.AsQueryable()
|
||||||
.Where(u => u.Id == w.AffinityId)
|
.Where(u => u.Id == w.AffinityId)
|
||||||
.Select(u => u.Username + "#" + u.Discriminator)
|
.Select(u => u.Username + "#" + u.Discriminator)
|
||||||
.FirstOrDefault(),
|
.FirstOrDefault(),
|
||||||
|
|
||||||
ClaimCount = _set
|
ClaimCount = ctx.WaifuInfo
|
||||||
.AsQueryable()
|
.AsQueryable()
|
||||||
.Count(x => x.ClaimerId == w.WaifuId),
|
.Count(x => x.ClaimerId == w.WaifuId),
|
||||||
|
|
||||||
ClaimerName = _context.Set<DiscordUser>()
|
ClaimerName = ctx.Set<DiscordUser>()
|
||||||
.AsQueryable()
|
.AsQueryable()
|
||||||
.Where(u => u.Id == w.ClaimerId)
|
.Where(u => u.Id == w.ClaimerId)
|
||||||
.Select(u => u.Username + "#" + u.Discriminator)
|
.Select(u => u.Username + "#" + u.Discriminator)
|
||||||
.FirstOrDefault(),
|
.FirstOrDefault(),
|
||||||
|
|
||||||
DivorceCount = _context
|
DivorceCount = ctx
|
||||||
.Set<WaifuUpdate>()
|
.Set<WaifuUpdate>()
|
||||||
.AsQueryable()
|
.AsQueryable()
|
||||||
.Count(x => x.OldId == w.WaifuId &&
|
.Count(x => x.OldId == w.WaifuId &&
|
||||||
@@ -168,14 +150,14 @@ VALUES ({null}, {null}, {1}, (SELECT Id FROM DiscordUser WHERE UserId={userId}))
|
|||||||
|
|
||||||
Price = w.Price,
|
Price = w.Price,
|
||||||
|
|
||||||
Claims = _set
|
Claims = ctx.WaifuInfo
|
||||||
.AsQueryable()
|
.AsQueryable()
|
||||||
.Include(x => x.Waifu)
|
.Include(x => x.Waifu)
|
||||||
.Where(x => x.ClaimerId == w.WaifuId)
|
.Where(x => x.ClaimerId == w.WaifuId)
|
||||||
.Select(x => x.Waifu.Username + "#" + x.Waifu.Discriminator)
|
.Select(x => x.Waifu.Username + "#" + x.Waifu.Discriminator)
|
||||||
.ToList(),
|
.ToList(),
|
||||||
|
|
||||||
Fans = _set
|
Fans = ctx.WaifuInfo
|
||||||
.AsQueryable()
|
.AsQueryable()
|
||||||
.Include(x => x.Waifu)
|
.Include(x => x.Waifu)
|
||||||
.Where(x => x.AffinityId == w.WaifuId)
|
.Where(x => x.AffinityId == w.WaifuId)
|
@@ -11,9 +11,6 @@ namespace NadekoBot.Services.Database
|
|||||||
{
|
{
|
||||||
public NadekoContext _context { get; }
|
public NadekoContext _context { get; }
|
||||||
|
|
||||||
private IWaifuRepository _waifus;
|
|
||||||
public IWaifuRepository Waifus => _waifus ?? (_waifus = new WaifuRepository(_context));
|
|
||||||
|
|
||||||
private IDiscordUserRepository _discordUsers;
|
private IDiscordUserRepository _discordUsers;
|
||||||
public IDiscordUserRepository DiscordUsers => _discordUsers ?? (_discordUsers = new DiscordUserRepository(_context));
|
public IDiscordUserRepository DiscordUsers => _discordUsers ?? (_discordUsers = new DiscordUserRepository(_context));
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user