feat(bot): remove hacky fix for extremely slow system deletes
they are no longer extremely slow
This commit is contained in:
		@@ -117,17 +117,6 @@ public class MessageCreated: IEventHandler<MessageCreateEvent>
 | 
				
			|||||||
        if (!HasCommandPrefix(content, ourUserId, out var cmdStart) || cmdStart == content.Length)
 | 
					        if (!HasCommandPrefix(content, ourUserId, out var cmdStart) || cmdStart == content.Length)
 | 
				
			||||||
            return false;
 | 
					            return false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (ctx.IsDeleting)
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            await _rest.CreateMessage(evt.ChannelId, new()
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                Content = $"{Emojis.Error} Your system is currently being deleted."
 | 
					 | 
				
			||||||
                    + " Due to database issues, it is not possible to use commands while a system is being deleted. Please wait a few minutes and try again.",
 | 
					 | 
				
			||||||
                MessageReference = new(guild?.Id, channel.Id, evt.Id)
 | 
					 | 
				
			||||||
            });
 | 
					 | 
				
			||||||
            return true;
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        // Trim leading whitespace from command without actually modifying the string
 | 
					        // Trim leading whitespace from command without actually modifying the string
 | 
				
			||||||
        // This just moves the argPos pointer by however much whitespace is at the start of the post-argPos string
 | 
					        // This just moves the argPos pointer by however much whitespace is at the start of the post-argPos string
 | 
				
			||||||
        var trimStartLengthDiff =
 | 
					        var trimStartLengthDiff =
 | 
				
			||||||
@@ -172,8 +161,6 @@ public class MessageCreated: IEventHandler<MessageCreateEvent>
 | 
				
			|||||||
    private async ValueTask<bool> TryHandleProxy(MessageCreateEvent evt, Guild guild, Channel channel,
 | 
					    private async ValueTask<bool> TryHandleProxy(MessageCreateEvent evt, Guild guild, Channel channel,
 | 
				
			||||||
                                                 MessageContext ctx)
 | 
					                                                 MessageContext ctx)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        if (ctx.IsDeleting) return false;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        var botPermissions = await _cache.PermissionsIn(channel.Id);
 | 
					        var botPermissions = await _cache.PermissionsIn(channel.Id);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        try
 | 
					        try
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -14,7 +14,6 @@ public class MessageContext
 | 
				
			|||||||
    /// <summary>
 | 
					    /// <summary>
 | 
				
			||||||
    /// Whether a system is being deleted (no actions should be taken, or commands ran)
 | 
					    /// Whether a system is being deleted (no actions should be taken, or commands ran)
 | 
				
			||||||
    /// </summary>
 | 
					    /// </summary>
 | 
				
			||||||
    public bool IsDeleting { get; }
 | 
					 | 
				
			||||||
    public ulong? LogChannel { get; }
 | 
					    public ulong? LogChannel { get; }
 | 
				
			||||||
    public bool InBlacklist { get; }
 | 
					    public bool InBlacklist { get; }
 | 
				
			||||||
    public bool InLogBlacklist { get; }
 | 
					    public bool InLogBlacklist { get; }
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,7 +1,6 @@
 | 
				
			|||||||
create function message_context(account_id bigint, guild_id bigint, channel_id bigint)
 | 
					create function message_context(account_id bigint, guild_id bigint, channel_id bigint)
 | 
				
			||||||
    returns table (
 | 
					    returns table (
 | 
				
			||||||
        system_id int,
 | 
					        system_id int,
 | 
				
			||||||
        is_deleting bool,
 | 
					 | 
				
			||||||
        log_channel bigint,
 | 
					        log_channel bigint,
 | 
				
			||||||
        in_blacklist bool,
 | 
					        in_blacklist bool,
 | 
				
			||||||
        in_log_blacklist bool,
 | 
					        in_log_blacklist bool,
 | 
				
			||||||
@@ -28,7 +27,6 @@ as $$
 | 
				
			|||||||
        guild as (select * from servers where id = guild_id)
 | 
					        guild as (select * from servers where id = guild_id)
 | 
				
			||||||
    select
 | 
					    select
 | 
				
			||||||
        system.id                                  as system_id,
 | 
					        system.id                                  as system_id,
 | 
				
			||||||
        system.is_deleting,
 | 
					 | 
				
			||||||
        guild.log_channel,
 | 
					        guild.log_channel,
 | 
				
			||||||
        (channel_id = any (guild.blacklist))       as in_blacklist,
 | 
					        (channel_id = any (guild.blacklist))       as in_blacklist,
 | 
				
			||||||
        (channel_id = any (guild.log_blacklist))   as in_log_blacklist,
 | 
					        (channel_id = any (guild.log_blacklist))   as in_log_blacklist,
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -144,7 +144,6 @@ public partial class ModelRepository
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    public async Task DeleteSystem(SystemId id)
 | 
					    public async Task DeleteSystem(SystemId id)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        await _db.Execute(c => c.QueryAsync("update systems set is_deleting = true where id = @id", new { id = id }));
 | 
					 | 
				
			||||||
        var query = new Query("systems").AsDelete().Where("id", id);
 | 
					        var query = new Query("systems").AsDelete().Where("id", id);
 | 
				
			||||||
        await _db.ExecuteQuery(query);
 | 
					        await _db.ExecuteQuery(query);
 | 
				
			||||||
        _logger.Information("Deleted {SystemId}", id);
 | 
					        _logger.Information("Deleted {SystemId}", id);
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user