From 013384c943836627da3751985e907ae88c3836d2 Mon Sep 17 00:00:00 2001 From: "Nyeki.py" <84998222+Nekidev@users.noreply.github.com> Date: Thu, 17 Oct 2024 19:28:08 -0300 Subject: [PATCH] fix(db): :wrench: Update pool size configurations. --- payphone/cogs/calls/cog.py | 11 +++++++++-- payphone/core/config.py | 16 +++++++++++++--- 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/payphone/cogs/calls/cog.py b/payphone/cogs/calls/cog.py index 5c45b50..9f4a434 100644 --- a/payphone/cogs/calls/cog.py +++ b/payphone/cogs/calls/cog.py @@ -9,7 +9,7 @@ from discord import errors from discord.ext import commands, tasks from discord.utils import find -from tortoise import transactions +from tortoise import transactions, exceptions import asyncpg.exceptions @@ -648,7 +648,14 @@ class Calls(base.Cog): channel = await utils.get_channel(message.channel) - call = await models.Call.get(id=channel.call_id).prefetch_related("channels") + try: + call = await models.Call.get(id=channel.call_id).prefetch_related( + "channels" + ) + + except exceptions.DoesNotExist: + await self.bot.redis.srem(constants.CHANNELS_ONCALL_SET, str(channel_id)) + return other_channel: models.Channel = find( lambda c: c.id != channel_id, call.channels diff --git a/payphone/core/config.py b/payphone/core/config.py index 923a280..ed415da 100644 --- a/payphone/core/config.py +++ b/payphone/core/config.py @@ -1,6 +1,7 @@ import os from dotenv import load_dotenv + load_dotenv() @@ -10,7 +11,18 @@ IS_DEBUG = os.environ.get("IS_DEBUG", "false") == "true" TORTOISE_ORM = { "connections": { - "default": f"postgres://payphone:payphone@{"localhost" if IS_DEBUG else "database"}/payphone", + "default": { + "engine": "tortoise.backends.asyncpg", + "credentials": { + "host": "localhost" if IS_DEBUG else "database", + "port": "5432", + "user": "payphone", + "password": "payphone", + "database": "payphone", + }, + "minsize": 5, + "maxsize": 1000, + }, }, "apps": { "models": { @@ -18,8 +30,6 @@ TORTOISE_ORM = { "default_connection": "default", } }, - "minsize": 5, - "maxsize": 1000 } SUGGESTIONS_CHANNEL_ID = int(os.getenv("SUGGESTIONS_CHANNEL_ID"))