两处提醒查询补 ORDER BY id,保证平局取舍可复现
reminder.js 扫全表和 index.js 的 getQuotaStatus 都没有 ORDER BY, 两边的 sort 又都是稳定排序,同一天、同 kind、同 importance 的条目 先后完全由 SQLite 返回顺序决定。一个走全表扫、一个可能走索引, 顺序一致纯属巧合——一旦不一致,首页预告的人名就和实际被跳过的人对不上。 Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -144,7 +144,11 @@ async function runForUser(openid, items, today = new Date()) {
|
||||
|
||||
async function runOnce() {
|
||||
console.log('[reminder] 开始扫描纪念日...')
|
||||
const list = db.prepare('SELECT * FROM anniversaries WHERE remindEnabled = 1').all()
|
||||
// ORDER BY id 不是为了排序好看,而是为了「平局可复现」:
|
||||
// 同一天、同 kind、同 importance 的条目在 sort 里比不出先后(JS sort 是稳定的),
|
||||
// 最终取舍就取决于 SQLite 的返回顺序。这里和 index.js 的 getQuotaStatus 必须用同一个
|
||||
// 兜底顺序,否则首页预告「谁有风险」的人名会和实际被跳过的人对不上。
|
||||
const list = db.prepare('SELECT * FROM anniversaries WHERE remindEnabled = 1 ORDER BY id').all()
|
||||
console.log(`[reminder] 启用提醒的纪念日 ${list.length} 条`)
|
||||
|
||||
// 额度是按用户算的,所以必须分组处理
|
||||
|
||||
Reference in New Issue
Block a user