This commit is contained in:
douboer
2025-10-21 10:46:03 +08:00
parent db9be32815
commit fb0f5ed9c5
20 changed files with 1869 additions and 103 deletions

View File

@@ -48,11 +48,11 @@ class BookListManager:
books_open = self.get_books_last_open()
this_year = today.year
for bk_id in booksinfo:
notes = annotations.get(bk_id, {})
notes = annotations.get(bk_id, []) # 现在是列表而不是字典
day_notes = {}
# 收集每本书所有笔记的创建时间,按天分组
# day_notes: {date对象: [datetime对象, ...]},便于后续统计每天的阅读行为
for uuid, note in notes.items():
for note in notes:
raw_date = note.get('creationdate')
try:
dt = datetime.datetime.strptime(raw_date, '%Y-%m-%d %H:%M:%S')
@@ -226,12 +226,8 @@ class BookListManager:
""")
rows = cur.fetchall()
conn.close()
# 调试:原始满足完成条件的行数
try:
if getattr(self, '_debug_finished_books', True):
print(f"[debug finished] raw_rows={len(rows)} (ZISFINISHED=1 & ZDATEFINISHED not null)")
except Exception:
pass
# 调试:原始满足完成条件的行数(已禁用)
# print(f"[debug finished] raw_rows={len(rows)} (ZISFINISHED=1 & ZDATEFINISHED not null)")
except Exception as e:
print(f'警告: 查询已读完书籍失败: {e}')
return results
@@ -247,13 +243,10 @@ class BookListManager:
results.append((asset_id, info, finished_dt))
except Exception:
pass
try:
if getattr(self, '_debug_finished_books', True):
print(f"[debug finished] after year filter={len(results)}, year={year}")
if results:
print("[debug finished] sample asset_ids:", ','.join(r[0] for r in results[:5]))
except Exception:
pass
# 调试信息(已禁用)
# print(f"[debug finished] after year filter={len(results)}, year={year}")
# if results:
# print("[debug finished] sample asset_ids:", ','.join(r[0] for r in results[:5]))
# 按完成时间倒序
results.sort(key=lambda x: x[2], reverse=True)
return results