Updated some namespaces, finished some todos. v5 should be cancelled probably as the code is too intertwined to make it modular

This commit is contained in:
Kwoth
2023-11-11 05:22:52 +00:00
parent a28be0d343
commit bc77783820
224 changed files with 308 additions and 317 deletions

View File

@@ -1,7 +1,7 @@
#nullable disable
using LinqToDB.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore;
using NadekoBot.Services.Database.Models;
using Nadeko.Bot.Db.Models;
namespace NadekoBot.Db;

View File

@@ -1,6 +1,6 @@
#nullable disable
using Microsoft.EntityFrameworkCore;
using NadekoBot.Services.Database.Models;
using Nadeko.Bot.Db.Models;
namespace NadekoBot.Db;

View File

@@ -1,8 +1,8 @@
#nullable disable
using Microsoft.EntityFrameworkCore;
using NadekoBot.Db.Models;
using NadekoBot.Services.Database;
using NadekoBot.Services.Database.Models;
using Nadeko.Bot.Db.Models;
namespace NadekoBot.Db;

View File

@@ -1,7 +1,7 @@
#nullable disable
using LinqToDB;
using Microsoft.EntityFrameworkCore;
using NadekoBot.Services.Database.Models;
using Nadeko.Bot.Db.Models;
namespace NadekoBot.Db;

View File

@@ -1,6 +1,6 @@
#nullable disable
using Microsoft.EntityFrameworkCore;
using NadekoBot.Services.Database.Models;
using Nadeko.Bot.Db.Models;
namespace NadekoBot.Db;
@@ -29,10 +29,8 @@ public static class QuoteExtensions
ulong guildId,
string keyword)
{
// todo figure shuffle out
return (await quotes.AsQueryable().Where(q => q.GuildId == guildId && q.Keyword == keyword).ToListAsync())
.Shuffle()
.FirstOrDefault();
return (await quotes.AsQueryable().Where(q => q.GuildId == guildId && q.Keyword == keyword).ToArrayAsync())
.RandomOrDefault();
}
public static async Task<Quote> SearchQuoteKeywordTextAsync(
@@ -41,15 +39,13 @@ public static class QuoteExtensions
string keyword,
string text)
{
var rngk = new NadekoRandom();
return (await quotes.AsQueryable()
.Where(q => q.GuildId == guildId
&& (keyword == null || q.Keyword == keyword)
&& (EF.Functions.Like(q.Text.ToUpper(), $"%{text.ToUpper()}%")
|| EF.Functions.Like(q.AuthorName, text)))
.ToListAsync())
.OrderBy(_ => rngk.Next())
.FirstOrDefault();
.ToArrayAsync())
.RandomOrDefault();
}
public static void RemoveAllByKeyword(this DbSet<Quote> quotes, ulong guildId, string keyword)

View File

@@ -1,6 +1,6 @@
#nullable disable
using Microsoft.EntityFrameworkCore;
using NadekoBot.Services.Database.Models;
using Nadeko.Bot.Db.Models;
namespace NadekoBot.Db;

View File

@@ -1,6 +1,6 @@
#nullable disable
using Microsoft.EntityFrameworkCore;
using NadekoBot.Services.Database.Models;
using Nadeko.Bot.Db.Models;
namespace NadekoBot.Db;

View File

@@ -2,8 +2,8 @@
using LinqToDB;
using LinqToDB.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore;
using NadekoBot.Services.Database;
using NadekoBot.Services.Database.Models;
using Nadeko.Bot.Db.Models;
namespace NadekoBot.Db;

View File

@@ -1,6 +1,6 @@
#nullable disable
using Microsoft.EntityFrameworkCore;
using NadekoBot.Services.Database.Models;
using Nadeko.Bot.Db.Models;
namespace NadekoBot.Db;