From f22dc7c35f62a267df6979ffab3acdb4239570db Mon Sep 17 00:00:00 2001 From: Cxx0822 <1556464090@qq.com> Date: Wed, 29 Oct 2025 16:40:55 +0800 Subject: [PATCH] =?UTF-8?q?feat:=E6=9B=B4=E6=96=B0=E5=8D=9A=E5=AE=A2?= =?UTF-8?q?=E6=8E=92=E5=BA=8F=E8=A7=84=E5=88=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/logging.py | 17 +++++++++-------- service/blog_service.py | 4 ++-- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/config/logging.py b/config/logging.py index 079c195..78815e3 100644 --- a/config/logging.py +++ b/config/logging.py @@ -75,15 +75,16 @@ logger.add( diagnose=True, # 显示详细异常信息 ) -logger.add( - log_to_fluent, - level=LOG_LEVEL, # 处理 INFO 及以上级别 - format="{message}", # 原始消息(实际使用结构化数据) - backtrace=True, # 启用堆栈回溯 - diagnose=True # 显示诊断信息 -) +if settings.ENVIRONMENT == 'docker': + logger.add( + log_to_fluent, + level=LOG_LEVEL, # 处理 INFO 及以上级别 + format="{message}", # 原始消息(实际使用结构化数据) + backtrace=True, # 启用堆栈回溯 + diagnose=True # 显示诊断信息 + ) -atexit.register(fluent_sender.close) + atexit.register(fluent_sender.close) # 导出配置好的logger __all__ = ["logger"] diff --git a/service/blog_service.py b/service/blog_service.py index cb09974..ff891e8 100644 --- a/service/blog_service.py +++ b/service/blog_service.py @@ -35,7 +35,7 @@ def query_blog_by_page(db: Session, current_page: int = 1, page_size: int = 10, ).outerjoin(BlogCategory, Blog.category_id == BlogCategory.id) .outerjoin(BlogVisit, Blog.id == BlogVisit.blog_id) .group_by(Blog.id, BlogCategory.name) - .order_by(desc(Blog.top_value), desc(Blog.update_time))) + .order_by(desc(Blog.is_great), desc(Blog.top_value), desc(Blog.update_time))) if not is_all: stmt = stmt.where(Blog.is_approved == 1) @@ -75,7 +75,7 @@ def query_blog_by_condition(db: Session, blog_query: BlogQuery) -> List[BlogResp if conditions: stmt = stmt.where(and_(*conditions)) - stmt = stmt.order_by(desc(Blog.update_time)) + stmt = stmt.order_by(desc(Blog.is_great), desc(Blog.update_time)) results = db.execute(stmt).fetchall()