Skip to content

Commit

Permalink
feat: heartbeat
Browse files Browse the repository at this point in the history
  • Loading branch information
Timeraa committed Aug 7, 2024
1 parent 20f1caf commit 684dcd0
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions apps/master/src/util/updateHeartbeats.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import pLimit from "p-limit";
import { mainLog, mongo, redis } from "../index.js";

const limit = pLimit(1);

const BATCH_SIZE = 10000;
export default async function () {
limit(async () => {
let count = 0;
Expand All @@ -13,7 +15,7 @@ export default async function () {
"pmd-api.heartbeatUpdates",
cursor,
"COUNT",
1000
BATCH_SIZE
);
cursor = result[0];

Expand Down Expand Up @@ -46,7 +48,7 @@ export default async function () {
);
log(
"Batch %s: Inserted %s entries, Updated %s entries",
Math.floor(count / 1000) + 1,
Math.floor(count / BATCH_SIZE) + 1,
res.upsertedCount,
res.modifiedCount
);
Expand Down

0 comments on commit 684dcd0

Please sign in to comment.