Skip to content

Commit

Permalink
Reduce query limit and reverse order
Browse files Browse the repository at this point in the history
  • Loading branch information
webmaster128 committed Apr 14, 2024
1 parent a70976e commit fb2b1c4
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions jobs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,11 @@ export class JobsChecker {
* Checks gateway for pending jobs and returns the rounds of those jobs as a list
*/
public async check(): Promise<number[]> {
const query = { jobs_desc: { offset: null, limit: 50 } };
const queryLimit = 4;

// Use jobs_asc because with jobs_desc all entries in the result might be in the (far) future,
// leading to cases where the unprocesses jobs in the past are not processed anymore.
const query = { jobs_asc: { offset: null, limit: queryLimit } };
const { jobs }: JobsResponse = await this.noisClient.queryContractSmart(this.gateway, query);
if (jobs.length === 0) return []; // Nothing to do for us

Expand All @@ -51,7 +55,7 @@ export class JobsChecker {
const due = timeOfRound(round) - Date.now();
return `#${round} (due ${formatDuration(due)})`;
});
console.log(`Jobs pending for rounds: %c${roundInfos.join(", ")}`, "color: orange");
console.log(`Top ${queryLimit} pending jobs: %c${roundInfos.join(", ")}`, "color: orange");
return rounds;
}
}

0 comments on commit fb2b1c4

Please sign in to comment.