fix(server): queue the backfill's updates instead of awaiting them in a loop

Server lint was red on dev: lint:warnings counted 557 no-await-in-loop warnings in src against a baseline of 556, from the UPDATE the new admin-made account backfill awaited per account. The updates are now queued with addSql, the way the Ireland counties migration queues its row writes, with the id checked to be an integer. The migration does the same as before; it has not shipped in a release.
This commit is contained in:
Maurice
2026-11-21 11:22:47 +01:00
parent 8fc9fe7945
commit 6861687b1f
@@ -84,11 +84,15 @@ export class Migration20200101046480_an_address_changed_after_an_admin_made_the_
const users = (await this.execute(
`SELECT id, email FROM users WHERE COALESCE(is_guest, 0) = 0 AND email_self_asserted = 0`,
)) as UserEmailRow[];
// Queued, run after up() returns; the id comes from the database and is
// checked to be an integer, nothing a user typed.
for (const user of users) {
const id = String(user.id);
if (!createdByAdmin.has(id) || editedByAdmin.has(id)) continue;
if (baselines.get(id)?.includes(user.email.trim().toLowerCase())) continue;
await this.execute('UPDATE users SET email_self_asserted = 1 WHERE id = ?', [user.id]);
const rowId = Number(user.id);
if (!Number.isInteger(rowId)) continue;
this.addSql(`UPDATE users SET email_self_asserted = 1 WHERE id = ${rowId}`);
}
}
}