diff --git a/database/src/database.ts b/database/src/database.ts index 3222417..d1a3616 100644 --- a/database/src/database.ts +++ b/database/src/database.ts @@ -444,7 +444,7 @@ export class Database implements Loggable { @timed async getDesignatedSenderCredentials() { const sql = this.#sql; const [first, ...rest] = - await sql`SELECT email, given_name, family_name, access_token, refresh_token, expiration FROM drap.designated_sender JOIN drap.candidate_senders cs USING (email) JOIN drap.users USING (email) WHERE user_id IS NOT NULL AND is_admin AND lab_id IS NULL FOR UPDATE OF cs`; + await sql`SELECT email, given_name, family_name, access_token, refresh_token, expiration FROM drap.designated_sender JOIN drap.candidate_senders cs USING (email) JOIN drap.users USING (email) WHERE user_id IS NOT NULL AND is_admin AND lab_id IS NULL`; strictEqual(rest.length, 0); return typeof first === 'undefined' ? null : parse(DesignatedSenderCredentials, first); } @@ -629,7 +629,7 @@ export class Database implements Loggable { @timed async getOneDraftNotification() { const sql = this.#sql; const [notif, ...rest] = - await sql`SELECT notif_id, draft_id, ty, round, dn.lab_id, lab_name, u.email, given_name, family_name FROM drap.draft_notifications dn LEFT JOIN drap.labs USING (lab_id) LEFT JOIN drap.users u USING (email) ORDER BY notif_id LIMIT 1 FOR UPDATE OF dn SKIP LOCKED`; + await sql`SELECT notif_id, draft_id, ty, round, dn.lab_id, lab_name, u.email, given_name, family_name FROM drap.draft_notifications dn LEFT JOIN drap.labs USING (lab_id) LEFT JOIN drap.users u USING (email) ORDER BY notif_id LIMIT 1 FOR UPDATE SKIP LOCKED`; strictEqual(rest.length, 0); return typeof notif === 'undefined' ? null : parse(DraftNotificationWithDetails, notif); } @@ -637,7 +637,7 @@ export class Database implements Loggable { @timed async getOneUserNotification() { const sql = this.#sql; const [notif, ...rest] = - await sql`SELECT notif_id, dn.lab_id, lab_name, email, given_name, family_name FROM drap.user_notifications dn JOIN drap.labs USING (lab_id) JOIN drap.users USING (email) ORDER BY notif_id LIMIT 1 FOR UPDATE OF dn SKIP LOCKED`; + await sql`SELECT notif_id, dn.lab_id, lab_name, email, given_name, family_name FROM drap.user_notifications dn JOIN drap.labs USING (lab_id) JOIN drap.users USING (email) ORDER BY notif_id LIMIT 1 FOR UPDATE SKIP LOCKED`; strictEqual(rest.length, 0); return typeof notif === 'undefined' ? null : parse(UserNotificationWithDetails, notif); }