From c9c5837b387c5dd6a583ba94ae225381baefb45a Mon Sep 17 00:00:00 2001 From: TheNoxium Date: Tue, 1 Apr 2025 14:20:40 +0500 Subject: [PATCH] fix: config, list events table --- api/api/config/default.py | 5 +++-- api/api/db/tables/events.py | 5 +---- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/api/api/config/default.py b/api/api/config/default.py index 3b3b025..392e51f 100644 --- a/api/api/config/default.py +++ b/api/api/config/default.py @@ -1,6 +1,7 @@ import uuid from os import environ +from functools import cached_property from pydantic import BaseModel from pydantic_settings import BaseSettings @@ -43,7 +44,7 @@ class DefaultSettings(BaseSettings): REDIS_DB: int = int(environ.get("REDIS_DB", "0")) REDIS_PASSWORD: str = environ.get("REDIS_PASSWORD", "hackme") - @property + @cached_property def database_settings(self) -> dict: """Get all settings for connection with database.""" return { @@ -54,7 +55,7 @@ class DefaultSettings(BaseSettings): "port": self.MYSQL_PORT, } - @property + @cached_property def database_uri(self) -> str: """Get uri for connection with database.""" uri = "mysql+aiomysql://{user}:{password}@{host}:{port}/{database}".format( diff --git a/api/api/db/tables/events.py b/api/api/db/tables/events.py index cc33c06..eb9c742 100644 --- a/api/api/db/tables/events.py +++ b/api/api/db/tables/events.py @@ -19,14 +19,11 @@ class EventStatus(str, Enum): list_events_table = Table( 'list_events', metadata, Column('id', UnsignedInt, primary_key=True, autoincrement=True), - Column('name', String(40, collation='latin1_bin'), nullable=False), + Column('name', String(40, collation='latin1_bin'), nullable=False,unique=True), Column('title', String(64), nullable=False), Column('creator_id', UnsignedInt, ForeignKey('account.id'), nullable=False), Column('created_at', DateTime(timezone=True), server_default=func.now()), Column('schema', JSON, default={}), Column('state', SQLAEnum(EventState), nullable=False), Column('status', SQLAEnum(EventStatus), nullable=False), - - - Index('UNIQUE_name', 'name', unique=True) )