I broke the Db I guess?

This commit is contained in:
Toastie (DCS Team) 2024-04-14 23:36:32 +12:00
parent b8df0d8b06
commit 1ee97675b0
Signed by: toastie_t0ast
GPG key ID: 27F3B6855AFD40A4
59 changed files with 149 additions and 93 deletions

View file

@ -1,4 +1,4 @@
#nullable disable #nullable disable
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using EllieBot.Db.Models; using EllieBot.Db.Models;

View file

@ -1,4 +1,4 @@
#nullable disable #nullable disable
using LinqToDB.EntityFrameworkCore; using LinqToDB.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using EllieBot.Services.Database.Models; using EllieBot.Services.Database.Models;
@ -12,9 +12,9 @@ public static class CurrencyTransactionExtensions
ulong userId, ulong userId,
int page) int page)
=> set.ToLinqToDBTable() => set.ToLinqToDBTable()
.Where(x => x.UserId == userId) .Where(x => x.UserId == userId)
.OrderByDescending(x => x.DateAdded) .OrderByDescending(x => x.DateAdded)
.Skip(15 * page) .Skip(15 * page)
.Take(15) .Take(15)
.ToListAsyncLinqToDB(); .ToListAsyncLinqToDB();
} }

View file

@ -1,4 +1,4 @@
#nullable disable #nullable disable
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using EllieBot.Services.Database.Models; using EllieBot.Services.Database.Models;

View file

@ -1,4 +1,4 @@
#nullable disable #nullable disable
using LinqToDB; using LinqToDB;
using LinqToDB.EntityFrameworkCore; using LinqToDB.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;

View file

@ -1,4 +1,4 @@
#nullable disable #nullable disable
using LinqToDB; using LinqToDB;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using EllieBot.Services.Database.Models; using EllieBot.Services.Database.Models;

View file

@ -1,4 +1,4 @@
#nullable disable #nullable disable
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using EllieBot.Services.Database.Models; using EllieBot.Services.Database.Models;

View file

@ -1,4 +1,4 @@
#nullable disable #nullable disable
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using EllieBot.Services.Database.Models; using EllieBot.Services.Database.Models;
@ -8,7 +8,7 @@ public static class MusicPlaylistExtensions
{ {
public static List<MusicPlaylist> GetPlaylistsOnPage(this DbSet<MusicPlaylist> playlists, int num) public static List<MusicPlaylist> GetPlaylistsOnPage(this DbSet<MusicPlaylist> playlists, int num)
{ {
if (num < 0) if (num < 1)
throw new ArgumentOutOfRangeException(nameof(num)); throw new ArgumentOutOfRangeException(nameof(num));
return playlists.AsQueryable().Skip((num - 1) * 20).Take(20).Include(pl => pl.Songs).ToList(); return playlists.AsQueryable().Skip((num - 1) * 20).Take(20).Include(pl => pl.Songs).ToList();

View file

@ -1,4 +1,4 @@
#nullable disable #nullable disable
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using EllieBot.Services.Database; using EllieBot.Services.Database;
using EllieBot.Services.Database.Models; using EllieBot.Services.Database.Models;
@ -20,6 +20,12 @@ public static class PollExtensions
if (p.Votes is not null) if (p.Votes is not null)
{ {
ctx.RemoveRange(p.Votes); ctx.RemoveRange(p.Votes);
p.Votes.Clear();
}
if (p.Answers is not null)
{
ctx.RemoveRange(p.Answers);
p.Answers.Clear(); p.Answers.Clear();
} }

View file

@ -1,4 +1,4 @@
#nullable disable #nullable disable
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using EllieBot.Services.Database.Models; using EllieBot.Services.Database.Models;

View file

@ -1,4 +1,4 @@
#nullable disable #nullable disable
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using EllieBot.Services.Database.Models; using EllieBot.Services.Database.Models;

View file

@ -1,4 +1,4 @@
#nullable disable #nullable disable
using LinqToDB; using LinqToDB;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using EllieBot.Services.Database; using EllieBot.Services.Database;

View file

@ -1,4 +1,4 @@
#nullable disable #nullable disable
using LinqToDB; using LinqToDB;
using LinqToDB.EntityFrameworkCore; using LinqToDB.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;

View file

@ -1,4 +1,4 @@
#nullable disable #nullable disable
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using EllieBot.Services.Database.Models; using EllieBot.Services.Database.Models;

View file

@ -1,4 +1,4 @@
#nullable disable #nullable disable
namespace EllieBot.Services.Database.Models; namespace EllieBot.Services.Database.Models;
public class AntiRaidSetting : DbEntity public class AntiRaidSetting : DbEntity
@ -11,10 +11,10 @@ public class AntiRaidSetting : DbEntity
public PunishmentAction Action { get; set; } public PunishmentAction Action { get; set; }
/// <summary> /// <summary>
/// Duration of the punishment, in minutes. This works only in supported Actions, like: /// Duration of the punishment, in minutes. This works only for supported Actions, like:
/// Mute, ChatMute, VoiceMute, etc... /// Mute, Chatmute, Voicemute, etc...
/// </summary> /// </summary>
public int PunishmentDuration { get; set; } public int PunishDuration { get; set; }
} }
public class AntiSpamSetting : DbEntity public class AntiSpamSetting : DbEntity

View file

@ -1,4 +1,4 @@
#nullable disable #nullable disable
namespace EllieBot.Services.Database.Models; namespace EllieBot.Services.Database.Models;
public class AutoCommand : DbEntity public class AutoCommand : DbEntity

View file

@ -1,4 +1,4 @@
using EllieBot.Services.Database.Models; using EllieBot.Services.Database.Models;
namespace EllieBot.Db.Models; namespace EllieBot.Db.Models;

View file

@ -1,4 +1,4 @@
#nullable disable #nullable disable
namespace EllieBot.Services.Database.Models; namespace EllieBot.Services.Database.Models;
public class AutoTranslateChannel : DbEntity public class AutoTranslateChannel : DbEntity

View file

@ -1,4 +1,4 @@
#nullable disable #nullable disable
namespace EllieBot.Services.Database.Models; namespace EllieBot.Services.Database.Models;
public class AutoTranslateUser : DbEntity public class AutoTranslateUser : DbEntity

View file

@ -1,4 +1,4 @@
#nullable disable #nullable disable
namespace EllieBot.Services.Database.Models; namespace EllieBot.Services.Database.Models;
public class BanTemplate : DbEntity public class BanTemplate : DbEntity

View file

@ -1,3 +1,4 @@
#nullable disable
namespace EllieBot.Services.Database.Models; namespace EllieBot.Services.Database.Models;
public class BlacklistEntry : DbEntity public class BlacklistEntry : DbEntity

View file

@ -9,7 +9,7 @@ public class ClubInfo : DbEntity
[MaxLength(20)] [MaxLength(20)]
public string Name { get; set; } public string Name { get; set; }
public string Description { get; set; } public string Description { get; set; }
public string ImageUrl { get; set; } public string ImageUrl { get; set; } = string.Empty;
public int Xp { get; set; } = 0; public int Xp { get; set; } = 0;
public int? OwnerId { get; set; } public int? OwnerId { get; set; }

View file

@ -1,4 +1,4 @@
#nullable disable #nullable disable
namespace EllieBot.Services.Database.Models; namespace EllieBot.Services.Database.Models;
public class CommandAlias : DbEntity public class CommandAlias : DbEntity

View file

@ -1,4 +1,4 @@
#nullable disable #nullable disable
namespace EllieBot.Services.Database.Models; namespace EllieBot.Services.Database.Models;
public class CommandCooldown : DbEntity public class CommandCooldown : DbEntity

View file

@ -1,4 +1,4 @@
#nullable disable #nullable disable
namespace EllieBot.Services.Database.Models; namespace EllieBot.Services.Database.Models;
public class DelMsgOnCmdChannel : DbEntity public class DelMsgOnCmdChannel : DbEntity

View file

@ -11,9 +11,10 @@ public class EllieExpression : DbEntity
public bool DmResponse { get; set; } public bool DmResponse { get; set; }
public bool ContainsAnywhere { get; set; } public bool ContainsAnywhere { get; set; }
public bool AllowTarget { get; set; } public bool AllowTarget { get; set; }
public string Reactions { get; set; }
public string[] GetReactions() public string[] GetReactions()
=> string.IsNullOrWhiteSpace(Reaactions) ? Array.Empty<string>() : Reaactions.Split("@@@"); => string.IsNullOrWhiteSpace(Reactions) ? Array.Empty<string>() : Reactions.Split("@@@");
public bool IsGlobal() public bool IsGlobal()
=> GuildId is null or 0; => GuildId is null or 0;

View file

@ -0,0 +1,49 @@
#nullable disable
namespace EllieBot.Services.Database.Models;
public class CurrencyEvent
{
public enum Type
{
Reaction,
GameStatus
//NotRaid,
}
public ulong ServerId { get; set; }
public ulong ChannelId { get; set; }
public ulong MessageId { get; set; }
public Type EventType { get; set; }
/// <summary>
/// Amount of currency that the user will be rewarded.
/// </summary>
public long Amount { get; set; }
/// <summary>
/// Maximum amount of currency that can be handed out.
/// </summary>
public long PotSize { get; set; }
public List<AwardedUser> AwardedUsers { get; set; }
/// <summary>
/// Used as extra data storage for events which need it.
/// </summary>
public ulong ExtraId { get; set; }
/// <summary>
/// May be used for some future event.
/// </summary>
public ulong ExtraId2 { get; set; }
/// <summary>
/// May be used for some future event.
/// </summary>
public string ExtraString { get; set; }
}
public class AwardedUser
{
}

View file

@ -1,4 +1,4 @@
#nullable disable #nullable disable
namespace EllieBot.Services.Database.Models; namespace EllieBot.Services.Database.Models;
public class FeedSub : DbEntity public class FeedSub : DbEntity

View file

@ -1,4 +1,4 @@
#nullable disable #nullable disable
namespace EllieBot.Services.Database.Models; namespace EllieBot.Services.Database.Models;
public class FilterChannelId : DbEntity public class FilterChannelId : DbEntity

View file

@ -1,4 +1,4 @@
#nullable disable #nullable disable
namespace EllieBot.Services.Database.Models; namespace EllieBot.Services.Database.Models;
public class FilterLinksChannelId : DbEntity public class FilterLinksChannelId : DbEntity

View file

@ -1,4 +1,4 @@
#nullable disable #nullable disable
namespace EllieBot.Services.Database.Models; namespace EllieBot.Services.Database.Models;
public class FilteredWord : DbEntity public class FilteredWord : DbEntity

View file

@ -1,4 +1,4 @@
#nullable disable #nullable disable
using EllieBot.Modules.Searches.Common; using EllieBot.Modules.Searches.Common;
using EllieBot.Services.Database.Models; using EllieBot.Services.Database.Models;

View file

@ -1,4 +1,4 @@
#nullable disable #nullable disable
namespace EllieBot.Services.Database.Models; namespace EllieBot.Services.Database.Models;
public class GCChannelId : DbEntity public class GCChannelId : DbEntity

View file

@ -1,4 +1,4 @@
#nullable disable #nullable disable
namespace EllieBot.Services.Database.Models; namespace EllieBot.Services.Database.Models;
public class GroupName : DbEntity public class GroupName : DbEntity

View file

@ -1,4 +1,4 @@
#nullable disable #nullable disable
using EllieBot.Db.Models; using EllieBot.Db.Models;
namespace EllieBot.Services.Database.Models; namespace EllieBot.Services.Database.Models;

View file

@ -26,10 +26,10 @@ public class LogSetting : DbEntity
public ulong? UserMutedId { get; set; } public ulong? UserMutedId { get; set; }
// userpresence //userpresence
public ulong? LogUserPresenceId { get; set; } public ulong? LogUserPresenceId { get; set; }
// voicepresence //voicepresence
public ulong? LogVoicePresenceId { get; set; } public ulong? LogVoicePresenceId { get; set; }
public ulong? LogVoicePresenceTTSId { get; set; } public ulong? LogVoicePresenceTTSId { get; set; }

View file

@ -1,4 +1,4 @@
#nullable disable #nullable disable
namespace EllieBot.Services.Database.Models; namespace EllieBot.Services.Database.Models;
public class MutedUserId : DbEntity public class MutedUserId : DbEntity

View file

@ -1,4 +1,4 @@
#nullable disable #nullable disable
namespace EllieBot.Db.Models; namespace EllieBot.Db.Models;
/// <summary> /// <summary>

View file

@ -1,10 +1,9 @@
#nullable disable #nullable disable
using System.ComponentModel.DataAnnotations.Schema; using System.ComponentModel.DataAnnotations.Schema;
using System.Diagnostics; using System.Diagnostics;
namespace EllieBot.Services.Database.Models; namespace EllieBot.Services.Database.Models;
[DebuggerDisplay("{PrimaryTarget}{SecondaryTarget} {SecondaryTargetName} {State} {PrimaryTargetId}")] [DebuggerDisplay("{PrimaryTarget}{SecondaryTarget} {SecondaryTargetName} {State} {PrimaryTargetId}")]
public class Permissionv2 : DbEntity, IIndexed public class Permissionv2 : DbEntity, IIndexed
{ {

View file

@ -1,4 +1,4 @@
#nullable disable #nullable disable
namespace EllieBot.Services.Database.Models; namespace EllieBot.Services.Database.Models;
public enum ShopEntryType public enum ShopEntryType

View file

@ -1,4 +1,4 @@
#nullable disable #nullable disable
namespace EllieBot.Services.Database.Models; namespace EllieBot.Services.Database.Models;
public class SlowmodeIgnoredRole : DbEntity public class SlowmodeIgnoredRole : DbEntity

View file

@ -1,4 +1,4 @@
#nullable disable #nullable disable
namespace EllieBot.Services.Database.Models; namespace EllieBot.Services.Database.Models;
public class SlowmodeIgnoredUser : DbEntity public class SlowmodeIgnoredUser : DbEntity

View file

@ -1,4 +1,4 @@
#nullable disable #nullable disable
using EllieBot.Services.Database.Models; using EllieBot.Services.Database.Models;
namespace EllieBot.Db.Models; namespace EllieBot.Db.Models;

View file

@ -1,4 +1,4 @@
#nullable disable #nullable disable
namespace EllieBot.Services.Database.Models; namespace EllieBot.Services.Database.Models;
public class StreamRoleSettings : DbEntity public class StreamRoleSettings : DbEntity

View file

@ -1,4 +1,4 @@
#nullable disable #nullable disable
namespace EllieBot.Services.Database.Models; namespace EllieBot.Services.Database.Models;
public class UnbanTimer : DbEntity public class UnbanTimer : DbEntity

View file

@ -1,4 +1,4 @@
#nullable disable #nullable disable
namespace EllieBot.Services.Database.Models; namespace EllieBot.Services.Database.Models;
public class UnmuteTimer : DbEntity public class UnmuteTimer : DbEntity

View file

@ -1,4 +1,4 @@
#nullable disable #nullable disable
namespace EllieBot.Services.Database.Models; namespace EllieBot.Services.Database.Models;
public class UnroleTimer : DbEntity public class UnroleTimer : DbEntity

View file

@ -1,4 +1,4 @@
#nullable disable #nullable disable
namespace EllieBot.Services.Database.Models; namespace EllieBot.Services.Database.Models;
public class VcRoleInfo : DbEntity public class VcRoleInfo : DbEntity

View file

@ -1,7 +1,7 @@
#nullable disable #nullable disable
namespace EllieBot.Services.Database.Models; namespace EllieBot.Services.Database.Models;
public class WaifuItem public class WaifuItem : DbEntity
{ {
public WaifuInfo WaifuInfo { get; set; } public WaifuInfo WaifuInfo { get; set; }
public int? WaifuInfoId { get; set; } public int? WaifuInfoId { get; set; }

View file

@ -1,4 +1,4 @@
#nullable disable #nullable disable
namespace EllieBot.Services.Database.Models; namespace EllieBot.Services.Database.Models;
public enum WarnExpireAction public enum WarnExpireAction

View file

@ -1,4 +1,4 @@
#nullable disable #nullable disable
namespace EllieBot.Services.Database.Models; namespace EllieBot.Services.Database.Models;
public class WarningPunishment : DbEntity public class WarningPunishment : DbEntity

View file

@ -1,4 +1,4 @@
#nullable disable #nullable disable
namespace EllieBot.Services.Database.Models; namespace EllieBot.Services.Database.Models;
public class XpSettings : DbEntity public class XpSettings : DbEntity

View file

@ -1,4 +1,4 @@
#nullable disable #nullable disable warnings
using EllieBot.Services.Database.Models; using EllieBot.Services.Database.Models;
namespace EllieBot.Db.Models; namespace EllieBot.Db.Models;

View file

@ -1,4 +1,4 @@
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using EllieBot.Db.Models; using EllieBot.Db.Models;
namespace EllieBot.Services.Database; namespace EllieBot.Services.Database;

View file

@ -1,8 +1,8 @@
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
namespace EllieBot.Services.Database; namespace EllieBot.Services.Database;
public class PostgreSqlContext : EllieContext public sealed class PostgreSqlContext : EllieContext
{ {
private readonly string _connStr; private readonly string _connStr;

View file

@ -1,4 +1,4 @@
using Microsoft.Data.Sqlite; using Microsoft.Data.Sqlite;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
namespace EllieBot.Services.Database; namespace EllieBot.Services.Database;