Update db.ts

通过读取缓存修复刚说话缺无法获取发言时间的问题
This commit is contained in:
po-lan 2024-07-05 12:12:40 +08:00 committed by GitHub
parent eb84e2f8c9
commit a9f3e7fc54
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -408,10 +408,12 @@ class DBUtil extends DBUtilBase {
logDebug('读取发言时间', groupId);
return new Promise<IRember[]>((resolve, reject) => {
this.db!.all(`SELECT * FROM "${groupId}" `, (err, rows: IRember[]) => {
const cache = this.LURCache.get(groupId).map(e=>({user_id:e.userId, last_sent_time:e.value}));
if (err) {
logError('查询发言时间失败', groupId);
return resolve([]);
return resolve(cache.map(e=>({...e, join_time:0})));
}
Object.assign(rows, cache)
logDebug('查询发言时间成功', groupId, rows);
resolve(rows);
});