mirror of
https://github.com/fawney19/Aether.git
synced 2026-09-02 01:10:23 +08:00
fix(announcement): 将分页计数移至排序之前执行
This commit is contained in:
@@ -79,15 +79,15 @@ class AnnouncementService:
|
||||
or_(Announcement.end_time == None, Announcement.end_time >= now),
|
||||
)
|
||||
|
||||
# 分页
|
||||
total = int(query.with_entities(func.count(Announcement.id)).scalar() or 0)
|
||||
|
||||
# 排序:置顶优先,然后按优先级和创建时间
|
||||
query = query.order_by(
|
||||
Announcement.is_pinned.desc(),
|
||||
Announcement.priority.desc(),
|
||||
Announcement.created_at.desc(),
|
||||
)
|
||||
|
||||
# 分页
|
||||
total = int(query.with_entities(func.count(Announcement.id)).scalar() or 0)
|
||||
announcements = query.offset(offset).limit(limit).all()
|
||||
|
||||
# 获取已读状态
|
||||
|
||||
Reference in New Issue
Block a user