From 524601afc3d94e8c3f3383015fc32cf8cf9680c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=94=B2=E8=BE=B0=E7=94=9F=E4=BA=A7?= Date: Fri, 17 Apr 2026 15:13:50 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=B8=80=E5=B0=98=E7=9C=8B=E6=9D=BF?= =?UTF-8?q?=E6=8C=89=E6=9C=80=E6=96=B0=E5=B8=96=E5=AD=90=E5=8F=91=E8=A1=A8?= =?UTF-8?q?=E6=97=B6=E9=97=B4=E6=8E=92=E5=BA=8F=20-=20=E4=BD=BF=E7=94=A8CO?= =?UTF-8?q?ALESCE(post=5Ftime,=20crawled=5Fat)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/app/routers/yichens.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/backend/app/routers/yichens.py b/backend/app/routers/yichens.py index de8e152..a4b5ef4 100644 --- a/backend/app/routers/yichens.py +++ b/backend/app/routers/yichens.py @@ -138,13 +138,13 @@ def get_posts( count_query = f"SELECT COUNT(*) FROM yichens_posts WHERE {where_sql}" total_count = db.execute(text(count_query), {k: v for k, v in params.items() if k not in ['limit', 'offset']}).scalar() or 0 - # 查询数据 + # 查询数据 - 有post_time时按post_time排序,没有时按crawled_at排序 data_query = f""" SELECT post_id, title, content, category, post_type, price, author_username, post_time, reply_count, view_count, url FROM yichens_posts WHERE {where_sql} - ORDER BY post_time DESC LIMIT :limit OFFSET :offset + ORDER BY COALESCE(post_time, crawled_at) DESC LIMIT :limit OFFSET :offset """ results = db.execute(text(data_query), params).fetchall()