Some packages updated, and small cleanup

This commit is contained in:
Toastie 2024-09-09 13:24:23 +12:00
parent 22d03005a1
commit 31ed61075e
No known key found for this signature in database
4 changed files with 203 additions and 8 deletions

View file

@ -88,7 +88,7 @@ public sealed class Bot : IBot
public IReadOnlyList<ulong> GetCurrentGuildIds()
=> Client.Guilds.Select(x => x.Id).ToList().ToList();
=> Client.Guilds.Select(x => x.Id).ToList().AsReadOnly();
private void AddServices()
{
@ -99,7 +99,7 @@ public sealed class Bot : IBot
using (var uow = _db.GetDbContext())
{
uow.EnsureUserCreated(bot.Id, bot.Username, bot.Discriminator, bot.AvatarId);
AllGuildConfigs = uow.Set<GuildConfig>().GetAllGuildConfigs(startingGuildIdList).ToImmutableArray();
AllGuildConfigs = uow.GuildConfigs.GetAllGuildConfigs(startingGuildIdList);
}
// var svcs = new StandardKernel(new NinjectSettings()

View file

@ -47,14 +47,18 @@ public static class GuildConfigExtensions
.Include(gc => gc.CommandCooldowns)
.Include(gc => gc.FollowedStreams)
.Include(gc => gc.StreamRole)
.Include(gc => gc.DelMsgOnCmdChannels)
.Include(gc => gc.XpSettings)
.ThenInclude(x => x.ExclusionList)
.Include(gc => gc.DelMsgOnCmdChannels);
.ThenInclude(x => x.ExclusionList);
public static IEnumerable<GuildConfig> GetAllGuildConfigs(
public static IReadOnlyCollection<GuildConfig> GetAllGuildConfigs(
this DbSet<GuildConfig> configs,
IReadOnlyList<ulong> availableGuilds)
=> configs.IncludeEverything().AsNoTracking().Where(x => availableGuilds.Contains(x.GuildId)).ToList();
=> configs.IncludeEverything()
.AsNoTracking()
.Where(x => availableGuilds.Contains(x.GuildId))
.ToList()
.AsReadOnly();
/// <summary>
/// Gets and creates if it doesn't exist a config for a guild.

View file

@ -81,7 +81,7 @@
<!-- Db-related packages -->
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.4" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.8" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.4">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
@ -89,7 +89,7 @@
<PackageReference Include="linq2db.EntityFrameworkCore" Version="8.1.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="8.0.4" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="8.0.8" />
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="8.0.4" />
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="8.0.2" />