@fullstackhouse/cerber 1.5.0 → 1.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/server/daemon.js +20 -6
- package/package.json +1 -1
package/dist/server/daemon.js
CHANGED
|
@@ -275,6 +275,10 @@ export function startDaemon(opts) {
|
|
|
275
275
|
/** When GitHub was last asked whether a settled row has been re-requested, by
|
|
276
276
|
* artifact id. In-memory for the same reason: a restart just asks sooner. */
|
|
277
277
|
const requestCheckedAt = new Map();
|
|
278
|
+
/** What the last poll's searches returned. A row that has just dropped out
|
|
279
|
+
* of them most likely merged or closed, so its state check skips the queue.
|
|
280
|
+
* In-memory: a restart just waits for the rotation, as before. */
|
|
281
|
+
let lastSearched = new Set();
|
|
278
282
|
/**
|
|
279
283
|
* What GitHub has for you: the PRs awaiting your review, then your own open
|
|
280
284
|
* ones, as one deduplicated list — and whether the second search ran at all
|
|
@@ -565,6 +569,14 @@ export function startDaemon(opts) {
|
|
|
565
569
|
await file({ at: new Date().toISOString(), reason: "request-withdrawn", review: null, reply: null }, "nobody is asking for this review any more", filedByWithdrawnRequest);
|
|
566
570
|
}
|
|
567
571
|
const awaitingIds = new Set(refs.map((r) => artifactId(r)));
|
|
572
|
+
// A row that left the searches since last poll is checked now, outside the
|
|
573
|
+
// cap and the leash: it is the one most likely to have merged, and behind
|
|
574
|
+
// the rotation of every open draft it could sit in the inbox for several
|
|
575
|
+
// polls. Without the own-PR search, every PR of yours would look like it left.
|
|
576
|
+
const me = ownSearched ? null : await who();
|
|
577
|
+
const searchedBefore = lastSearched;
|
|
578
|
+
lastSearched = awaitingIds;
|
|
579
|
+
const leftSearch = (a) => searchedBefore.has(a.id) && (ownSearched || (me !== null && !isOwnPr(a.pr, me)));
|
|
568
580
|
let refreshed = 0;
|
|
569
581
|
for (const artifact of await listArtifacts()) {
|
|
570
582
|
if (artifact.status === "running")
|
|
@@ -602,12 +614,14 @@ export function startDaemon(opts) {
|
|
|
602
614
|
// Anything with real work in it: periodically confirm the PR is still
|
|
603
615
|
// open, so merged/closed ones stop cluttering the queue. Capped and
|
|
604
616
|
// spaced out — this is book-keeping, not a data feed.
|
|
605
|
-
if (
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
617
|
+
if (!leftSearch(artifact)) {
|
|
618
|
+
if (refreshed >= STATE_REFRESH_CAP)
|
|
619
|
+
continue;
|
|
620
|
+
const last = stateCheckedAt.get(artifact.id) ?? 0;
|
|
621
|
+
if (Date.now() - last < STATE_REFRESH_MIN_MS)
|
|
622
|
+
continue;
|
|
623
|
+
refreshed++;
|
|
624
|
+
}
|
|
611
625
|
stateCheckedAt.set(artifact.id, Date.now());
|
|
612
626
|
try {
|
|
613
627
|
const pr = await fetchPrInfo(artifact.pr);
|
package/package.json
CHANGED