From bc96757a403e467a7e8e29fad36954f0e65cd6e5 Mon Sep 17 00:00:00 2001 From: sunlin92 Date: Wed, 16 Mar 2022 10:00:00 +0800 Subject: [PATCH 1/7] =?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 a5d58ead42ab90ab58a0df24d002acb6c0a7bc6e Mon Sep 17 00:00:00 2001 From: sunlin92 Date: Wed, 16 Mar 2022 10:15:57 +0800 Subject: [PATCH 2/7] 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 9ec9332fcf44555014b9d403b2fe3e4297e16fbf Mon Sep 17 00:00:00 2001 From: sunlin92 Date: Wed, 16 Mar 2022 10:19:23 +0800 Subject: [PATCH 3/7] =?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 428837e3c7a1681d602e7983bd4bae04e2481629 Mon Sep 17 00:00:00 2001 From: sunlin92 Date: Wed, 16 Mar 2022 12:07:57 +0800 Subject: [PATCH 4/7] =?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 ee364eb4e3374899ac32c68c004292360f8d4da1 Mon Sep 17 00:00:00 2001 From: sunlin92 Date: Wed, 16 Mar 2022 15:05:51 +0800 Subject: [PATCH 5/7] =?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, } # 令牌配置 From e3228823dfc86cebb9db1f0bfecebc1f70d993da Mon Sep 17 00:00:00 2001 From: sunlin92 Date: Wed, 16 Mar 2022 18:46:22 +0800 Subject: [PATCH 6/7] =?UTF-8?q?fix:=20/cms/user/permissions=20=E5=93=8D?= =?UTF-8?q?=E5=BA=94=E5=BC=82=E5=B8=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/cms/user.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/app/api/cms/user.py b/app/api/cms/user.py index 8ae9457..c24c534 100644 --- a/app/api/cms/user.py +++ b/app/api/cms/user.py @@ -38,7 +38,6 @@ LoginSchema, LoginTokenSchema, UserBaseInfoSchema, - UserPermissionSchema, UserRegisterSchema, UserSchema, ) @@ -215,7 +214,7 @@ def refresh(): @api.validate( tags=["用户"], security=[AuthorizationBearerSecurity], - resp=DocResponse(r=UserPermissionSchema), + # resp=DocResponse(r=UserPermissionSchema), # 当前数据接口无法使用OpenAPI表示 ) def get_allowed_apis(): """ From 89a385dddd8cc2a82a8d6af29014d72c18ac2d00 Mon Sep 17 00:00:00 2001 From: sunlin92 Date: Wed, 16 Mar 2022 19:12:31 +0800 Subject: [PATCH 7/7] =?UTF-8?q?update:=E6=9B=B4=E6=96=B0=E4=BE=9D=E8=B5=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pyproject.toml | 10 +++++----- requirements-dev.txt | 8 ++++---- requirements-prod.txt | 4 ++-- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index b8f91e5..39ac74e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -12,10 +12,10 @@ default = true [tool.poetry.dependencies] python = "^3.8" Lin-CMS = "^0.4.8" -pillow = "^9.0.0" +pillow = "^9.0.1" flask-cors = "^3.0.10" gunicorn = "^20.1.0" -gevent = "^21.8.0" +gevent = "^21.12.0" flask-socketio = "^5.1.1" blinker = "^1.4" python-dotenv = "^0.19.2" @@ -24,12 +24,12 @@ pydantic = {extras = ["email"], version = "^1.9.0"} [tool.poetry.dev-dependencies] flask-sqlacodegen = "^1.1.8" -black = "^21.10b0" +black = "^21.12b0" isort = "^5.10.1" watchdog = "^2.1.6" -coverage = "^6.1.2" +coverage = "^6.3.2" pytest = "^6.2.5" -pre-commit = "^2.16.0" +pre-commit = "^2.17.0" pytest-ordering = "^0.6" flake8 = "^4.0.1" diff --git a/requirements-dev.txt b/requirements-dev.txt index f8314e5..1e43a41 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -1,5 +1,5 @@ Lin-CMS==0.4.8 -pillow==9.0.0 +pillow==9.0.1 flask-cors==3.0.10 gunicorn==20.1.0 gevent==21.8.0 @@ -8,11 +8,11 @@ blinker==1.4 python-dotenv==0.19.2 gevent-websocket==0.10.1 flask-sqlacodegen==1.1.8 -black==21.10b0 +black==21.12b0 isort==5.10.1 watchdog==2.1.6 -coverage==6.1.2 +coverage==6.3.2 pytest==6.2.5 -pre-commit==2.16.0 +pre-commit==2.17.0 pytest-ordering==0.6 flake8==4.0.1 diff --git a/requirements-prod.txt b/requirements-prod.txt index 183e718..63e9944 100644 --- a/requirements-prod.txt +++ b/requirements-prod.txt @@ -1,8 +1,8 @@ Lin-CMS==0.4.8 -pillow==9.0.0 +pillow==9.0.1 flask-cors==3.0.10 gunicorn==20.1.0 -gevent==21.8.0 +gevent==21.12.0 flask-socketio==5.1.1 blinker==1.4 python-dotenv==0.19.2