From eeed9849ef650441458ead2d08d92b3fad3978c5 Mon Sep 17 00:00:00 2001 From: jxxghp Date: Mon, 21 Oct 2024 13:07:47 +0800 Subject: [PATCH] =?UTF-8?q?SubscribeHistory=20=E8=A1=A8=E7=BB=93=E6=9E=84?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/core/config.py | 8 +++--- app/db/models/subscribehistory.py | 10 ++++++-- database/versions/ecf3c693fdf3_2_0_5.py | 34 +++++++++++++++++++++++++ requirements.txt | 21 +++++++-------- 4 files changed, 55 insertions(+), 18 deletions(-) create mode 100644 database/versions/ecf3c693fdf3_2_0_5.py diff --git a/app/core/config.py b/app/core/config.py index 88009064..c6fffe22 100644 --- a/app/core/config.py +++ b/app/core/config.py @@ -58,12 +58,12 @@ class ConfigModel(BaseModel): DB_POOL_TYPE: str = "QueuePool" # 是否在获取连接时进行预先 ping 操作,默认关闭 DB_POOL_PRE_PING: bool = False - # 数据库连接池的大小,默认 20 - DB_POOL_SIZE: int = 20 + # 数据库连接池的大小,默认 100 + DB_POOL_SIZE: int = 100 # 数据库连接的回收时间(秒),默认 1800 秒 DB_POOL_RECYCLE: int = 1800 - # 数据库连接池获取连接的超时时间(秒),默认 30 秒 - DB_POOL_TIMEOUT: int = 30 + # 数据库连接池获取连接的超时时间(秒),默认 60 秒 + DB_POOL_TIMEOUT: int = 60 # 数据库连接池最大溢出连接数,默认 10 DB_MAX_OVERFLOW: int = 10 # SQLite 的 busy_timeout 参数,默认为 60 秒 diff --git a/app/db/models/subscribehistory.py b/app/db/models/subscribehistory.py index 28b147a6..9a19a397 100644 --- a/app/db/models/subscribehistory.py +++ b/app/db/models/subscribehistory.py @@ -1,4 +1,4 @@ -from sqlalchemy import Column, Integer, String, Sequence, Float +from sqlalchemy import Column, Integer, String, Sequence, Float, JSON from sqlalchemy.orm import Session from app.db import db_query, Base @@ -53,13 +53,19 @@ class SubscribeHistory(Base): # 订阅用户 username = Column(String) # 订阅站点 - sites = Column(String) + sites = Column(JSON) # 是否洗版 best_version = Column(Integer, default=0) # 保存路径 save_path = Column(String) # 是否使用 imdbid 搜索 search_imdbid = Column(Integer, default=0) + # 自定义识别词 + custom_words = Column(String) + # 自定义媒体类别 + media_category = Column(String) + # 过滤规则组 + filter_groups = Column(JSON, default=list) @staticmethod @db_query diff --git a/database/versions/ecf3c693fdf3_2_0_5.py b/database/versions/ecf3c693fdf3_2_0_5.py new file mode 100644 index 00000000..d0ea8119 --- /dev/null +++ b/database/versions/ecf3c693fdf3_2_0_5.py @@ -0,0 +1,34 @@ +"""2.0.5 + +Revision ID: ecf3c693fdf3 +Revises: a73f2dbf5c09 +Create Date: 2024-10-21 12:36:20.631963 + +""" +import contextlib + +from alembic import op +import sqlalchemy as sa + + +# revision identifiers, used by Alembic. +revision = 'ecf3c693fdf3' +down_revision = 'a73f2dbf5c09' +branch_labels = None +depends_on = None + + +def upgrade() -> None: + # ### commands auto generated by Alembic - please adjust! ### + # 将String转换为JSON类型 + with contextlib.suppress(Exception): + op.alter_column('subscribehistory', 'sites', existing_type=sa.String(), type_=sa.JSON()) + with contextlib.suppress(Exception): + op.add_column('subscribehistory', sa.Column('custom_words', sa.String(), nullable=True)) + op.add_column('subscribehistory', sa.Column('media_category', sa.String(), nullable=True)) + op.add_column('subscribehistory', sa.Column('filter_groups', sa.JSON(), nullable=True)) + # ### end Alembic commands ### + + +def downgrade() -> None: + pass diff --git a/requirements.txt b/requirements.txt index a6fde3b9..fec660fb 100644 --- a/requirements.txt +++ b/requirements.txt @@ -65,11 +65,6 @@ click==8.1.7 # uvicorn cn2an==0.5.22 # via -r requirements.in -colorama==0.4.6 - # via - # click - # qrcode - # tqdm coloredlogs==15.0.1 # via aligo crcmod==1.7 @@ -102,9 +97,7 @@ frozenlist==1.4.1 func-timeout==4.3.5 # via -r requirements.in greenlet==2.0.2 - # via - # playwright - # sqlalchemy + # via playwright h11==0.14.0 # via # httpcore @@ -192,6 +185,14 @@ pyee==9.0.4 # via playwright pyjwt==2.7.0 # via -r requirements.in +pyobjc-core==10.3.1 + # via + # pyobjc-framework-cocoa + # pyobjc-framework-quartz +pyobjc-framework-cocoa==10.3.1 + # via pyobjc-framework-quartz +pyobjc-framework-quartz==10.3.1 + # via pystray pyotp==2.9.0 # via -r requirements.in pyparsing==3.0.9 @@ -200,8 +201,6 @@ pypng==0.20220715.0 # via qrcode pyquery==2.0.0 # via -r requirements.in -pyreadline3==3.5.4 - # via humanfriendly pysocks==1.7.1 # via requests pystray==0.19.5 @@ -303,8 +302,6 @@ typing-extensions==4.12.2 # qrcode # sqlalchemy # transmission-rpc -tzdata==2024.2 - # via tzlocal tzlocal==5.2 # via # apscheduler