fix: sqlite condition in MonthlyUsageService

This commit is contained in:
KernelDeimos 2024-08-14 17:20:09 -04:00
parent bf4ba3f1d6
commit d4319ea072

View File

@ -33,6 +33,7 @@ class MonthlyUsageService extends BaseService {
const month = new Date().getUTCMonth() + 1; const month = new Date().getUTCMonth() + 1;
const maybe_app_id = actor.type.app?.id; const maybe_app_id = actor.type.app?.id;
const stringified = JSON.stringify(extra);
// UPSERT increment count // UPSERT increment count
await this.db.write( await this.db.write(
@ -45,8 +46,8 @@ class MonthlyUsageService extends BaseService {
'DO UPDATE SET `count` = `count` + 1, `extra` = ?', 'DO UPDATE SET `count` = `count` + 1, `extra` = ?',
}), }),
[ [
year, month, key, actor.type.user.id, maybe_app_id ?? null, JSON.stringify(extra), year, month, key, actor.type.user.id, maybe_app_id ?? null, stringified,
...this.db.case({ mysql: [JSON.stringify(extra)], otherwise: [JSON.stringify({ a: 1 })] }), stringified,
] ]
); );
} }