fix: 修复文件夹过滤时分页总数计算错误
This commit is contained in:
@@ -326,7 +326,7 @@ class Database:
|
||||
return items
|
||||
|
||||
def count_items(self, type: str = None, status: str = None, tag: str = None,
|
||||
keyword: str = None, starred: bool = None) -> int:
|
||||
keyword: str = None, starred: bool = None, folder_id: int = None) -> int:
|
||||
"""计算符合条件的条目总数"""
|
||||
with self.get_conn() as conn:
|
||||
cursor = conn.cursor()
|
||||
@@ -358,6 +358,15 @@ class Database:
|
||||
keyword_pattern = f"%{keyword}%"
|
||||
params.extend([keyword_pattern, keyword_pattern, keyword_pattern])
|
||||
|
||||
# 文件夹过滤
|
||||
if folder_id is not None:
|
||||
if folder_id == -1:
|
||||
# 未分类:folder_id为NULL
|
||||
conditions.append("i.folder_id IS NULL")
|
||||
else:
|
||||
conditions.append("i.folder_id = ?")
|
||||
params.append(folder_id)
|
||||
|
||||
if conditions:
|
||||
query += " WHERE " + " AND ".join(conditions)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user