generated from coulomb/repo-seed
Load limiting safeguards
This commit is contained in:
@@ -3,23 +3,24 @@ title: Todo
|
||||
---
|
||||
|
||||
```js
|
||||
import {API, POLL} from "./components/config.js";
|
||||
import {API, POLL_HEAVY, apiFetch, pollDelay, sleep} from "./components/config.js";
|
||||
const THIS_REPO = "the-custodian";
|
||||
```
|
||||
|
||||
```js
|
||||
// Live poll: tasks + workstreams + topics + contributions
|
||||
const todoState = (async function*() {
|
||||
let failures = 0;
|
||||
while (true) {
|
||||
let tasks = [], contribs = [], improvements = [], wsMap = {}, ok = false;
|
||||
try {
|
||||
const [rt, rw, rto, rr, rc, ri] = await Promise.all([
|
||||
fetch(`${API}/tasks/?limit=500`),
|
||||
fetch(`${API}/workstreams/`),
|
||||
fetch(`${API}/topics/`),
|
||||
fetch(`${API}/repos/`),
|
||||
fetch(`${API}/contributions/`),
|
||||
fetch(`${API}/technical-debt/?debt_type=dashboard-improvement`),
|
||||
apiFetch("/tasks/?limit=500"),
|
||||
apiFetch("/workstreams/"),
|
||||
apiFetch("/topics/"),
|
||||
apiFetch("/repos/"),
|
||||
apiFetch("/contributions/"),
|
||||
apiFetch("/technical-debt/?debt_type=dashboard-improvement"),
|
||||
]);
|
||||
ok = rt.ok && rw.ok && rto.ok && rr.ok && rc.ok;
|
||||
if (ok) {
|
||||
@@ -42,8 +43,9 @@ const todoState = (async function*() {
|
||||
improvements = ri.ok ? (await ri.json()).filter(t => t.debt_type === "dashboard-improvement" && !CLOSED.has(t.status)) : [];
|
||||
}
|
||||
} catch {}
|
||||
failures = ok ? 0 : failures + 1;
|
||||
yield {tasks, contribs, improvements, ok, ts: new Date()};
|
||||
await new Promise(res => setTimeout(res, POLL));
|
||||
await sleep(pollDelay({ok, base: POLL_HEAVY, failures}));
|
||||
}
|
||||
})();
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user