Skip to content

Commit 0c49ccb

Browse files
committed
Async fn
1 parent fc468f7 commit 0c49ccb

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

src/jobs.ts

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -220,12 +220,14 @@ export function registerJobs() {
220220
// });
221221
});
222222

223-
while (true) {
224-
const minuteCronStart = performance.now();
225-
track("job-sync");
226-
// Loop through users.
227-
app.logger.info("SELECTING...");
228-
sql`select * from users where clan_id is not null;`.then(async (users) => {
223+
(async function () {
224+
while (true) {
225+
const minuteCronStart = performance.now();
226+
track("job-sync");
227+
// Loop through users.
228+
app.logger.info("SELECTING...");
229+
const users = await sql`select * from users where clan_id is not null;`;
230+
229231
users.forEach(async (user) => {
230232
for (
231233
let date = eventStartDate;
@@ -261,6 +263,6 @@ export function registerJobs() {
261263
text: `sync job took ${performance.now() - minuteCronStart} ms`,
262264
channel: "U03DFNYGPCN", // @Malted
263265
});
264-
});
265-
}
266+
}
267+
})();
266268
}

0 commit comments

Comments
 (0)