fix: sqlite syntax inconsistency

The SQL statement for creating a group uses syntax that only works under
sqlite. This was caused by introducing anomaly detection when a user
creates a large number of groups in quick succession.
This commit is contained in:
KernelDeimos
2025-05-02 14:34:46 -04:00
parent 4647e2d9c0
commit 75aebd6d35

View File

@@ -105,8 +105,11 @@ class GroupService extends BaseService {
const [{ n_groups }] = await this.db.read(
"SELECT COUNT(*) AS n_groups FROM `group` WHERE " +
"owner_user_id=? AND " +
"created_at >= datetime('now', '-1 hour')",
"owner_user_id=? AND created_at >= " +
this.db.case({
sqlite: "datetime('now', '-1 hour')",
otherwise: "NOW() - INTERVAL 1 HOUR"
}),
[owner_user_id]
);