From 6169786c709a00d23dbf9b960dd7849b7a61bc42 Mon Sep 17 00:00:00 2001 From: Jokky <36814905+Jokky6@users.noreply.github.com> Date: Mon, 7 Feb 2022 17:34:36 +0800 Subject: [PATCH 1/6] Update requirements-dev.txt --- requirements-dev.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/requirements-dev.txt b/requirements-dev.txt index 9db4d7c..d347e6e 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -1,4 +1,3 @@ -python==3.8 Lin-CMS==0.4.5 pillow==9.0.0 flask-cors==3.0.10 From a2184c87f7e192a2c12a25df350c04d0606696a0 Mon Sep 17 00:00:00 2001 From: sunlin92 Date: Wed, 16 Mar 2022 10:00:00 +0800 Subject: [PATCH 2/6] =?UTF-8?q?fix:=20mariadb=E5=85=BC=E5=AE=B9=E6=80=A7?= =?UTF-8?q?=E9=97=AE=E9=A2=98(close=20#195)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/cms/admin.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/api/cms/admin.py b/app/api/cms/admin.py index 04a21ec..bcf9b7b 100644 --- a/app/api/cms/admin.py +++ b/app/api/cms/admin.py @@ -77,13 +77,17 @@ def get_admin_users(query: QueryPageSchema): .scalar() ) # 获取当前分页条件下查询到的非Root组的用户id - current_page_user_ids = ( + query_current_page_user_ids = ( db.session.query(manager.user_group_model.user_id) .filter(~manager.user_group_model.group_id.in_(query_root_group_id)) .group_by(manager.user_group_model.user_id) .offset(g.offset) .limit(g.count) ) + # 部分数据库不支持子语句 in limit + current_page_user_ids = [ + user_id[0] for user_id in query_current_page_user_ids.all() + ] # 获取用户的基本信息 current_page_users = manager.user_model.query.filter( manager.user_model.id.in_(current_page_user_ids) From e9b61e1a605e8660955e3b1cee70e65e09512d6b Mon Sep 17 00:00:00 2001 From: sunlin92 Date: Wed, 16 Mar 2022 10:15:57 +0800 Subject: [PATCH 3/6] update: lincms v0.4.8 --- pyproject.toml | 2 +- requirements-dev.txt | 2 +- requirements-prod.txt | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 646e6d4..b8f91e5 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -11,7 +11,7 @@ default = true [tool.poetry.dependencies] python = "^3.8" -Lin-CMS = "^0.4.7" +Lin-CMS = "^0.4.8" pillow = "^9.0.0" flask-cors = "^3.0.10" gunicorn = "^20.1.0" diff --git a/requirements-dev.txt b/requirements-dev.txt index 4194ae4..f8314e5 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -1,4 +1,4 @@ -Lin-CMS==0.4.7 +Lin-CMS==0.4.8 pillow==9.0.0 flask-cors==3.0.10 gunicorn==20.1.0 diff --git a/requirements-prod.txt b/requirements-prod.txt index d50f689..183e718 100644 --- a/requirements-prod.txt +++ b/requirements-prod.txt @@ -1,4 +1,4 @@ -Lin-CMS==0.4.7 +Lin-CMS==0.4.8 pillow==9.0.0 flask-cors==3.0.10 gunicorn==20.1.0 From 66d49e3cfbee381d4c2629b01af7f48258decefc Mon Sep 17 00:00:00 2001 From: sunlin92 Date: Wed, 16 Mar 2022 10:19:23 +0800 Subject: [PATCH 4/6] =?UTF-8?q?refactor:=20=E7=A7=BB=E9=99=A4=E6=9C=AA?= =?UTF-8?q?=E4=BD=BF=E7=94=A8=E7=9A=84=E5=BC=95=E5=85=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/cms/schema/admin.py | 2 +- app/api/cms/schema/user.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/api/cms/schema/admin.py b/app/api/cms/schema/admin.py index e342887..7923c39 100644 --- a/app/api/cms/schema/admin.py +++ b/app/api/cms/schema/admin.py @@ -3,7 +3,7 @@ from lin import BaseModel, ParameterError from pydantic import Field, validator -from app.schema import BasePageSchema, QueryPageSchema +from app.schema import BasePageSchema from . import EmailSchema, GroupIdListSchema diff --git a/app/api/cms/schema/user.py b/app/api/cms/schema/user.py index 9bb8ccd..b19083d 100644 --- a/app/api/cms/schema/user.py +++ b/app/api/cms/schema/user.py @@ -2,7 +2,7 @@ from typing import List, Optional from lin import BaseModel, ParameterError -from pydantic import AnyHttpUrl, Field, validator +from pydantic import Field, validator from . import EmailSchema, GroupIdListSchema, ResetPasswordSchema From 600082e0ac28bdd27fb83039679463605758faee Mon Sep 17 00:00:00 2001 From: sunlin92 Date: Wed, 16 Mar 2022 12:07:57 +0800 Subject: [PATCH 5/6] =?UTF-8?q?feat:=20=E8=B0=83=E6=95=B4=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E5=BA=93=E9=93=BE=E6=8E=A5=E5=BC=95=E6=93=8E=E9=85=8D?= =?UTF-8?q?=E7=BD=AE=E5=A2=9E=E5=BC=BA=E5=85=B6=E5=8F=AF=E9=9D=A0=E6=80=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/config/base.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/app/config/base.py b/app/config/base.py index 7049db3..2828895 100644 --- a/app/config/base.py +++ b/app/config/base.py @@ -4,6 +4,7 @@ """ import os +import multiprocessing from datetime import timedelta @@ -29,6 +30,13 @@ class BaseConfig(object): # 屏蔽 sql alchemy 的 FSADeprecationWarning SQLALCHEMY_TRACK_MODIFICATIONS = False + # flask-sqlalchemy 引擎配置 + SQLALCHEMY_ENGINE_OPTIONS = { + "pool_pre_ping": True, # 每次请求前 pre-ping一下数据库, 防止db gone away + "pool_size": multiprocessing.cpu_count() * 2 + 1, + "pool_recycle": 600, # 小于等于数据库连接主动回收时间 + } + # 令牌配置 JWT_ACCESS_TOKEN_EXPIRES = timedelta(hours=1) From 76ef0bb92d6d39e2b3735115c5ea7d70ab9a5ac5 Mon Sep 17 00:00:00 2001 From: sunlin92 Date: Wed, 16 Mar 2022 15:05:51 +0800 Subject: [PATCH 6/6] =?UTF-8?q?=E5=8F=96=E6=B6=88sqlalchemy=20pool=5Fsize?= =?UTF-8?q?=E9=85=8D=E7=BD=AE=E4=BB=A5=E5=85=BC=E5=AE=B9sqlalchemy?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/config/base.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/app/config/base.py b/app/config/base.py index 2828895..9db84b4 100644 --- a/app/config/base.py +++ b/app/config/base.py @@ -4,7 +4,6 @@ """ import os -import multiprocessing from datetime import timedelta @@ -32,9 +31,12 @@ class BaseConfig(object): # flask-sqlalchemy 引擎配置 SQLALCHEMY_ENGINE_OPTIONS = { - "pool_pre_ping": True, # 每次请求前 pre-ping一下数据库, 防止db gone away - "pool_size": multiprocessing.cpu_count() * 2 + 1, - "pool_recycle": 600, # 小于等于数据库连接主动回收时间 + # sqlite 不支持pool_size, 其他数据库按需配置 + # "pool_size": 10, + # 每次请求前 pre-ping一下数据库, 防止db gone away + "pool_pre_ping": True, + # 小于等于数据库连接主动回收时间 + "pool_recycle": 600, } # 令牌配置