[Mod] Only loop through guilds in config when checking tempbans #4907

Merged
PredaaA merged 6 commits from admincog-tempbans into V3/develop 2021-04-03 23:59:42 +02:00
PredaaA commented 2021-03-21 22:33:18 +01:00 (Migrated from github.com)

Type

  • Bugfix
  • Enhancement
  • New feature

Description of the changes

Looping through all bot guilds was taking on bot performances way too much as it was almost directly looking to config.

### Type - [ ] Bugfix - [x] Enhancement - [ ] New feature ### Description of the changes Looping through all bot guilds was taking on bot performances way too much as it was almost directly looking to config.
Jackenmen (Migrated from github.com) requested changes 2021-04-03 02:13:52 +02:00
Jackenmen (Migrated from github.com) left a comment

This is a great improvement, I have just a few review comments before we can get this merged.

This is a great improvement, I have just a few review comments before we can get this merged.
@ -229,43 +229,63 @@ class KickBanMixin(MixinMeta):
return True, success_message
Jackenmen (Migrated from github.com) commented 2021-04-03 01:56:14 +02:00

Copying is needed so that guild_tempbans.remove(uid) works in the loop:

                        for uid in guild_tempbans.copy():
Copying is needed so that `guild_tempbans.remove(uid)` works in the loop: ```suggestion for uid in guild_tempbans.copy(): ```
Jackenmen (Migrated from github.com) commented 2021-04-03 01:56:49 +02:00

This doesn't really need to be in finally so let's keep it simple:

            await asyncio.sleep(60)
This doesn't really need to be in finally so let's keep it simple: ```suggestion await asyncio.sleep(60) ```
Jackenmen (Migrated from github.com) commented 2021-04-03 02:12:24 +02:00

It would be good to use either of

async with self.config.guild(guild).current_tempbans.get_lock():
    ...

async with self.config.guild(guild).current_tempbans():
    ...

to avoid a situation where we replace some tempban accidentally which doesn't seem that unlikely when you consider that this task runs every minute.

It would be good to use either of ``` async with self.config.guild(guild).current_tempbans.get_lock(): ... async with self.config.guild(guild).current_tempbans(): ... ``` to avoid a situation where we replace some tempban accidentally which doesn't seem *that* unlikely when you consider that this task runs every minute.
PredaaA commented 2021-04-03 21:51:15 +02:00 (Migrated from github.com)

Updated the PR with requested changes.

Updated the PR with requested changes.
Jackenmen commented 2021-04-03 23:11:05 +02:00 (Migrated from github.com)

The indentation levels on this method started to get a bit ridiculous so I went ahead and split this into more methods :)

The indentation levels on this method started to get a bit ridiculous so I went ahead and split this into more methods :)
Jackenmen (Migrated from github.com) approved these changes 2021-04-03 23:58:44 +02:00
Jackenmen (Migrated from github.com) left a comment

Looks good to me, thanks for working on speeding up Red.

Looks good to me, thanks for working on speeding up Red.
Sign in to join this conversation.
No reviewers
No labels
Automated PR
Blocked
Blocked By: Damage Control
Blocked By: Dependency
Blocked By: Other PR
Breaking Change
Category: CI
Category: Cogs - Admin
Category: Cogs - Alias
Category: Cogs - Audio
Category: Cogs - Bank
Category: Cogs - Cleanup
Category: Cogs - CustomCommands
Category: Cogs - Dev
Category: Cogs - Downloader
Category: Cogs - Economy
Category: Cogs - Filter
Category: Cogs - General
Category: Cogs - Image
Category: Cogs - Mod
Category: Cogs - Modlog
Category: Cogs - Mutes
Category: Cogs - Permissions
Category: Cogs - Reports
Category: Cogs - Streams
Category: Cogs - Trivia
Category: Cogs - Trivia - Lists
Category: Cogs - Warnings
Category: Core - API - App Commands Package
Category: Core - API - Audio
Category: Core - API - Bank
Category: Core - API - Commands Package
Category: Core - API - Config
Category: Core - API - Other
Category: Core - API - Utils Package
Category: Core - Bot Class
Category: Core - Bot Commands
Category: Core - Command-line Interfaces
Category: Core - Downloader
Category: Core - Help
Category: Core - i18n
Category: Core - Modlog
Category: Core - Other Internals
Category: Core - RPC/ZMQ
Category: Docker
Category: Docs - Changelogs
Category: Docs - For Developers
Category: Docs - Install Guides
Category: Docs - Other
Category: Docs - User Guides
Category: Meta
Category: RPC/ZMQ methods
Category: Vendored Packages
Changelog Entry: Added
Changelog Entry: Pending
Changelog Entry: Skipped
Closed: Duplicate
Closed: External
Closed: Invalid
Closed: User Error
Closed: Won't Fix
Complex Issue
Docs-only
Feature Branch
Good First Issue
Help Wanted
High Priority
Needs Backport To stable-docs
No Activity
No Repro
QA: Bypassed
QA: Changes Requested
QA: Passed
Release Blocker
Status: Accepted
Status: Frozen
Status: In Progress
Status: Needs Discussion
Status: Needs Info
Status: Needs Triage
Status: PRs Welcome
Type: Bug
Type: Dependency Update
Type: Deprecation
Type: Enhancement
Type: Feature
Type: Informational
Type: Merge
Type: Optimisation
Type: Question
Type: Removal
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
Mrcoolgamer11/Red-DiscordBot!4907
No description provided.