generated from coulomb/repo-seed
Load limiting safeguards
This commit is contained in:
@@ -3,22 +3,24 @@ title: Capability Requests
|
||||
---
|
||||
|
||||
```js
|
||||
import {API} from "./components/config.js";
|
||||
import {API, apiFetch, pollDelay, sleep} from "./components/config.js";
|
||||
const POLL = 30_000;
|
||||
```
|
||||
|
||||
```js
|
||||
// Live poll for capability requests
|
||||
const reqState = (async function*() {
|
||||
let failures = 0;
|
||||
while (true) {
|
||||
let data = [], ok = false;
|
||||
try {
|
||||
const r = await fetch(`${API}/capability-requests/`);
|
||||
const r = await apiFetch("/capability-requests/");
|
||||
ok = r.ok;
|
||||
data = ok ? await r.json() : [];
|
||||
} catch {}
|
||||
failures = ok ? 0 : failures + 1;
|
||||
yield {data, ok, ts: new Date()};
|
||||
await new Promise(res => setTimeout(res, POLL));
|
||||
await sleep(pollDelay({ok, base: POLL, failures}));
|
||||
}
|
||||
})();
|
||||
```
|
||||
@@ -198,14 +200,17 @@ display(Inputs.table(filtered.map(r => ({
|
||||
```js
|
||||
// Live poll for catalog entries
|
||||
const catalogState = (async function*() {
|
||||
let failures = 0;
|
||||
while (true) {
|
||||
let data = [];
|
||||
let data = [], ok = false;
|
||||
try {
|
||||
const r = await fetch(`${API}/capability-catalog/?status=all`);
|
||||
const r = await apiFetch("/capability-catalog/?status=all");
|
||||
ok = r.ok;
|
||||
if (r.ok) data = await r.json();
|
||||
} catch {}
|
||||
failures = ok ? 0 : failures + 1;
|
||||
yield data;
|
||||
await new Promise(res => setTimeout(res, POLL));
|
||||
await sleep(pollDelay({ok, base: POLL, failures}));
|
||||
}
|
||||
})();
|
||||
```
|
||||
|
||||
@@ -1,2 +1,27 @@
|
||||
export const API = "http://127.0.0.1:8000";
|
||||
export const POLL = 15_000;
|
||||
export const POLL_HEAVY = 60_000;
|
||||
export const POLL_HIDDEN = 120_000;
|
||||
export const FETCH_TIMEOUT = 12_000;
|
||||
|
||||
export function pollDelay({ok = true, base = POLL, failures = 0} = {}) {
|
||||
const hidden = typeof document !== "undefined" && document.visibilityState === "hidden";
|
||||
const failureDelay = ok ? base : Math.min(base * 2 ** Math.min(failures, 4), 300_000);
|
||||
return hidden ? Math.max(failureDelay, POLL_HIDDEN) : failureDelay;
|
||||
}
|
||||
|
||||
export function sleep(ms) {
|
||||
return new Promise(resolve => setTimeout(resolve, ms));
|
||||
}
|
||||
|
||||
export async function apiFetch(path, options = {}) {
|
||||
const url = path.startsWith("http") ? path : `${API}${path}`;
|
||||
const timeout = options.timeout ?? FETCH_TIMEOUT;
|
||||
const ctrl = new AbortController();
|
||||
const timer = setTimeout(() => ctrl.abort(), timeout);
|
||||
try {
|
||||
return await fetch(url, {...options, signal: ctrl.signal});
|
||||
} finally {
|
||||
clearTimeout(timer);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,22 +3,24 @@ title: Contributions
|
||||
---
|
||||
|
||||
```js
|
||||
import {API} from "./components/config.js";
|
||||
import {API, apiFetch, pollDelay, sleep} from "./components/config.js";
|
||||
const POLL = 30_000;
|
||||
```
|
||||
|
||||
```js
|
||||
// Live poll for contributions
|
||||
const contribState = (async function*() {
|
||||
let failures = 0;
|
||||
while (true) {
|
||||
let data = [], ok = false;
|
||||
try {
|
||||
const r = await fetch(`${API}/contributions/`);
|
||||
const r = await apiFetch("/contributions/");
|
||||
ok = r.ok;
|
||||
data = ok ? await r.json() : [];
|
||||
} catch {}
|
||||
failures = ok ? 0 : failures + 1;
|
||||
yield {data, ok, ts: new Date()};
|
||||
await new Promise(res => setTimeout(res, POLL));
|
||||
await sleep(pollDelay({ok, base: POLL, failures}));
|
||||
}
|
||||
})();
|
||||
```
|
||||
|
||||
@@ -3,18 +3,19 @@ title: Decisions
|
||||
---
|
||||
|
||||
```js
|
||||
import {API, POLL} from "./components/config.js";
|
||||
import {API, POLL_HEAVY, apiFetch, pollDelay, sleep} from "./components/config.js";
|
||||
```
|
||||
|
||||
```js
|
||||
// Fetch decisions + topics (for domain context) in parallel
|
||||
const decState = (async function*() {
|
||||
let failures = 0;
|
||||
while (true) {
|
||||
let data = [], ok = false;
|
||||
try {
|
||||
const [rd, rt] = await Promise.all([
|
||||
fetch(`${API}/decisions/?limit=500`),
|
||||
fetch(`${API}/topics/`),
|
||||
apiFetch("/decisions/?limit=500"),
|
||||
apiFetch("/topics/"),
|
||||
]);
|
||||
ok = rd.ok && rt.ok;
|
||||
if (ok) {
|
||||
@@ -43,8 +44,9 @@ const decState = (async function*() {
|
||||
});
|
||||
}
|
||||
} catch {}
|
||||
failures = ok ? 0 : failures + 1;
|
||||
yield {data, ok, ts: new Date()};
|
||||
await new Promise(res => setTimeout(res, POLL));
|
||||
await sleep(pollDelay({ok, base: POLL_HEAVY, failures}));
|
||||
}
|
||||
})();
|
||||
```
|
||||
|
||||
@@ -3,20 +3,21 @@ title: Dependencies
|
||||
---
|
||||
|
||||
```js
|
||||
import {API, POLL} from "./components/config.js";
|
||||
import {API, POLL_HEAVY, apiFetch, pollDelay, sleep} from "./components/config.js";
|
||||
```
|
||||
|
||||
```js
|
||||
// Fetch workstreams + topics + summary (summary carries dep edges on open_workstreams)
|
||||
const depState = (async function*() {
|
||||
let failures = 0;
|
||||
while (true) {
|
||||
let wsMap = {}, edges = [], ok = false;
|
||||
try {
|
||||
const [rw, rto, rr, rs] = await Promise.all([
|
||||
fetch(`${API}/workstreams/`),
|
||||
fetch(`${API}/topics/`),
|
||||
fetch(`${API}/repos/`),
|
||||
fetch(`${API}/state/summary`),
|
||||
apiFetch("/workstreams/"),
|
||||
apiFetch("/topics/"),
|
||||
apiFetch("/repos/"),
|
||||
apiFetch("/state/summary", {timeout: 20_000}),
|
||||
]);
|
||||
ok = rw.ok && rto.ok && rr.ok && rs.ok;
|
||||
if (ok) {
|
||||
@@ -38,8 +39,9 @@ const depState = (async function*() {
|
||||
}
|
||||
}
|
||||
} catch {}
|
||||
failures = ok ? 0 : failures + 1;
|
||||
yield {wsMap, edges, ok, ts: new Date()};
|
||||
await new Promise(res => setTimeout(res, POLL));
|
||||
await sleep(pollDelay({ok, base: POLL_HEAVY, failures}));
|
||||
}
|
||||
})();
|
||||
```
|
||||
|
||||
@@ -3,25 +3,27 @@ title: Domains
|
||||
---
|
||||
|
||||
```js
|
||||
import {API, POLL} from "./components/config.js";
|
||||
import {API, POLL_HEAVY, apiFetch, pollDelay, sleep} from "./components/config.js";
|
||||
```
|
||||
|
||||
```js
|
||||
const domainsState = (async function*() {
|
||||
let failures = 0;
|
||||
while (true) {
|
||||
let domains = [], repos = [], ok = false;
|
||||
try {
|
||||
const [rd, rr] = await Promise.all([
|
||||
fetch(`${API}/domains/?status=all`),
|
||||
fetch(`${API}/repos/`),
|
||||
apiFetch("/domains/?status=all"),
|
||||
apiFetch("/repos/"),
|
||||
]);
|
||||
ok = rd.ok && rr.ok;
|
||||
if (ok) {
|
||||
[domains, repos] = await Promise.all([rd.json(), rr.json()]);
|
||||
}
|
||||
} catch {}
|
||||
failures = ok ? 0 : failures + 1;
|
||||
yield {domains, repos, ok, ts: new Date()};
|
||||
await new Promise(res => setTimeout(res, POLL));
|
||||
await sleep(pollDelay({ok, base: POLL_HEAVY, failures}));
|
||||
}
|
||||
})();
|
||||
```
|
||||
|
||||
@@ -3,19 +3,20 @@ title: Extension Points
|
||||
---
|
||||
|
||||
```js
|
||||
import {API, POLL} from "./components/config.js";
|
||||
import {API, POLL_HEAVY, apiFetch, pollDelay, sleep} from "./components/config.js";
|
||||
```
|
||||
|
||||
```js
|
||||
const epState = (async function*() {
|
||||
let failures = 0;
|
||||
while (true) {
|
||||
let data = [], ok = false;
|
||||
try {
|
||||
const [re, rw, rt, rr] = await Promise.all([
|
||||
fetch(`${API}/extension-points/`),
|
||||
fetch(`${API}/workstreams/`),
|
||||
fetch(`${API}/topics/`),
|
||||
fetch(`${API}/repos/`),
|
||||
apiFetch("/extension-points/"),
|
||||
apiFetch("/workstreams/"),
|
||||
apiFetch("/topics/"),
|
||||
apiFetch("/repos/"),
|
||||
]);
|
||||
ok = re.ok && rw.ok && rt.ok && rr.ok;
|
||||
if (ok) {
|
||||
@@ -36,8 +37,9 @@ const epState = (async function*() {
|
||||
});
|
||||
}
|
||||
} catch {}
|
||||
failures = ok ? 0 : failures + 1;
|
||||
yield {data, ok, ts: new Date()};
|
||||
await new Promise(res => setTimeout(res, POLL));
|
||||
await sleep(pollDelay({ok, base: POLL_HEAVY, failures}));
|
||||
}
|
||||
})();
|
||||
```
|
||||
|
||||
@@ -3,20 +3,21 @@ title: Goals
|
||||
---
|
||||
|
||||
```js
|
||||
import {API} from "./components/config.js";
|
||||
import {API, apiFetch, pollDelay, sleep} from "./components/config.js";
|
||||
const POLL = 20_000;
|
||||
```
|
||||
|
||||
```js
|
||||
const goalsState = (async function*() {
|
||||
let failures = 0;
|
||||
while (true) {
|
||||
let domains = [], domainGoals = [], repoGoals = [], repos = [], ok = false;
|
||||
try {
|
||||
const [rd, rdg, rrg, rr] = await Promise.all([
|
||||
fetch(`${API}/domains/?status=active`),
|
||||
fetch(`${API}/domain-goals/`),
|
||||
fetch(`${API}/repo-goals/`),
|
||||
fetch(`${API}/repos/`),
|
||||
apiFetch("/domains/?status=active"),
|
||||
apiFetch("/domain-goals/"),
|
||||
apiFetch("/repo-goals/"),
|
||||
apiFetch("/repos/"),
|
||||
]);
|
||||
ok = rd.ok && rdg.ok && rrg.ok && rr.ok;
|
||||
if (ok) {
|
||||
@@ -25,8 +26,9 @@ const goalsState = (async function*() {
|
||||
]);
|
||||
}
|
||||
} catch {}
|
||||
failures = ok ? 0 : failures + 1;
|
||||
yield {domains, domainGoals, repoGoals, repos, ok, ts: new Date()};
|
||||
await new Promise(res => setTimeout(res, POLL));
|
||||
await sleep(pollDelay({ok, base: POLL, failures}));
|
||||
}
|
||||
})();
|
||||
```
|
||||
|
||||
@@ -3,21 +3,23 @@ title: Agent Inbox
|
||||
---
|
||||
|
||||
```js
|
||||
import {API, POLL} from "./components/config.js";
|
||||
import {API, apiFetch, pollDelay, sleep} from "./components/config.js";
|
||||
```
|
||||
|
||||
```js
|
||||
// Live poll: messages list
|
||||
const inboxState = (async function*() {
|
||||
let failures = 0;
|
||||
while (true) {
|
||||
let messages = [], ok = false;
|
||||
try {
|
||||
const resp = await fetch(`${API}/messages/?limit=100`);
|
||||
const resp = await apiFetch("/messages/?limit=100");
|
||||
ok = resp.ok;
|
||||
if (ok) messages = await resp.json();
|
||||
} catch {}
|
||||
failures = ok ? 0 : failures + 1;
|
||||
yield {messages, ok, ts: new Date()};
|
||||
await new Promise(res => setTimeout(res, POLL));
|
||||
await sleep(pollDelay({ok, failures}));
|
||||
}
|
||||
})();
|
||||
```
|
||||
|
||||
@@ -3,23 +3,25 @@ title: Overview
|
||||
---
|
||||
|
||||
```js
|
||||
import {API, POLL} from "./components/config.js";
|
||||
import {API, POLL, POLL_HEAVY, apiFetch, pollDelay, sleep} from "./components/config.js";
|
||||
```
|
||||
|
||||
```js
|
||||
// Live polling — yields {data, ok, ts} every POLL ms
|
||||
// Live polling — yields {data, ok, ts}; backs off when the API is slow/offline.
|
||||
const summaryState = (async function*() {
|
||||
let failures = 0;
|
||||
while (true) {
|
||||
let data, ok = false;
|
||||
try {
|
||||
const r = await fetch(`${API}/state/summary`);
|
||||
const r = await apiFetch("/state/summary", {timeout: 20_000});
|
||||
ok = r.ok;
|
||||
data = ok ? await r.json() : {error: `HTTP ${r.status}`};
|
||||
} catch (e) {
|
||||
data = {error: "API unreachable"};
|
||||
}
|
||||
failures = ok ? 0 : failures + 1;
|
||||
yield {data, ok, ts: new Date()};
|
||||
await new Promise(res => setTimeout(res, POLL));
|
||||
await sleep(pollDelay({ok, base: POLL_HEAVY, failures}));
|
||||
}
|
||||
})();
|
||||
```
|
||||
@@ -49,17 +51,20 @@ refreshDecisions();
|
||||
```js
|
||||
// SBOM snapshots — repo coverage and total package count
|
||||
const sbomSnapState = (async function*() {
|
||||
let failures = 0;
|
||||
while (true) {
|
||||
let snapshots = [], totalPkgs = 0;
|
||||
let snapshots = [], totalPkgs = 0, ok = false;
|
||||
try {
|
||||
const r = await fetch(`${API}/sbom/snapshots/`);
|
||||
const r = await apiFetch("/sbom/snapshots/");
|
||||
ok = r.ok;
|
||||
if (r.ok) {
|
||||
snapshots = await r.json();
|
||||
totalPkgs = snapshots.reduce((s, sn) => s + (sn.entry_count ?? 0), 0);
|
||||
}
|
||||
} catch {}
|
||||
failures = ok ? 0 : failures + 1;
|
||||
yield {snapshots, totalPkgs};
|
||||
await new Promise(res => setTimeout(res, POLL));
|
||||
await sleep(pollDelay({ok, base: POLL_HEAVY, failures}));
|
||||
}
|
||||
})();
|
||||
```
|
||||
@@ -67,17 +72,20 @@ const sbomSnapState = (async function*() {
|
||||
```js
|
||||
// Registered projects — milestone events tagged with registration
|
||||
const regsState = (async function*() {
|
||||
let failures = 0;
|
||||
while (true) {
|
||||
let rows = [];
|
||||
let rows = [], ok = false;
|
||||
try {
|
||||
const r = await fetch(`${API}/progress/?event_type=milestone&limit=500`);
|
||||
const r = await apiFetch("/progress/?event_type=milestone&limit=500");
|
||||
ok = r.ok;
|
||||
if (r.ok) {
|
||||
const all = await r.json();
|
||||
rows = all.filter(e => e.summary?.startsWith("Project registered with State Hub:"));
|
||||
}
|
||||
} catch {}
|
||||
failures = ok ? 0 : failures + 1;
|
||||
yield rows;
|
||||
await new Promise(res => setTimeout(res, POLL));
|
||||
await sleep(pollDelay({ok, base: POLL_HEAVY, failures}));
|
||||
}
|
||||
})();
|
||||
```
|
||||
@@ -85,15 +93,16 @@ const regsState = (async function*() {
|
||||
```js
|
||||
// All-workstreams + all-tasks poll — drives the multi-mode chart
|
||||
const wsChartState = (async function*() {
|
||||
let failures = 0;
|
||||
while (true) {
|
||||
let wsAll = [], ok = false;
|
||||
try {
|
||||
const [rw, rt, rto, rr, rwi] = await Promise.all([
|
||||
fetch(`${API}/workstreams/`),
|
||||
fetch(`${API}/tasks/?limit=2000`),
|
||||
fetch(`${API}/topics/`),
|
||||
fetch(`${API}/repos/`),
|
||||
fetch(`${API}/workstreams/workplan-index`),
|
||||
apiFetch("/workstreams/"),
|
||||
apiFetch("/tasks/?limit=2000"),
|
||||
apiFetch("/topics/"),
|
||||
apiFetch("/repos/"),
|
||||
apiFetch("/workstreams/workplan-index"),
|
||||
]);
|
||||
ok = rw.ok && rt.ok && rto.ok && rr.ok;
|
||||
if (ok) {
|
||||
@@ -132,8 +141,9 @@ const wsChartState = (async function*() {
|
||||
});
|
||||
}
|
||||
} catch {}
|
||||
failures = ok ? 0 : failures + 1;
|
||||
yield {wsAll, ok};
|
||||
await new Promise(res => setTimeout(res, POLL));
|
||||
await sleep(pollDelay({ok, base: POLL_HEAVY, failures}));
|
||||
}
|
||||
})();
|
||||
```
|
||||
|
||||
@@ -3,20 +3,21 @@ title: Interventions
|
||||
---
|
||||
|
||||
```js
|
||||
import {API, POLL} from "./components/config.js";
|
||||
import {API, POLL_HEAVY, apiFetch, pollDelay, sleep} from "./components/config.js";
|
||||
```
|
||||
|
||||
```js
|
||||
// Live poll: all tasks (filtered client-side) + workstreams + topics
|
||||
const interventionState = (async function*() {
|
||||
let failures = 0;
|
||||
while (true) {
|
||||
let tasks = [], wsMap = {}, ok = false;
|
||||
try {
|
||||
const [rt, rw, rto, rr] = await Promise.all([
|
||||
fetch(`${API}/tasks/?limit=500`),
|
||||
fetch(`${API}/workstreams/`),
|
||||
fetch(`${API}/topics/`),
|
||||
fetch(`${API}/repos/`),
|
||||
apiFetch("/tasks/?limit=500"),
|
||||
apiFetch("/workstreams/"),
|
||||
apiFetch("/topics/"),
|
||||
apiFetch("/repos/"),
|
||||
]);
|
||||
ok = rt.ok && rw.ok && rto.ok && rr.ok;
|
||||
if (ok) {
|
||||
@@ -36,8 +37,9 @@ const interventionState = (async function*() {
|
||||
}));
|
||||
}
|
||||
} catch {}
|
||||
failures = ok ? 0 : failures + 1;
|
||||
yield {tasks, ok, ts: new Date()};
|
||||
await new Promise(res => setTimeout(res, POLL));
|
||||
await sleep(pollDelay({ok, base: POLL_HEAVY, failures}));
|
||||
}
|
||||
})();
|
||||
```
|
||||
|
||||
@@ -3,24 +3,26 @@ title: Progress
|
||||
---
|
||||
|
||||
```js
|
||||
import {API, POLL} from "./components/config.js";
|
||||
import {POLL_HEAVY, apiFetch, pollDelay, sleep} from "./components/config.js";
|
||||
```
|
||||
|
||||
```js
|
||||
const progState = (async function*() {
|
||||
let failures = 0;
|
||||
while (true) {
|
||||
let data = [], tokenEvents = [], ok = false;
|
||||
try {
|
||||
const [r1, r2] = await Promise.all([
|
||||
fetch(`${API}/progress/?limit=500`),
|
||||
fetch(`${API}/token-events/?limit=1000`),
|
||||
apiFetch("/progress/?limit=500"),
|
||||
apiFetch("/token-events/?limit=1000"),
|
||||
]);
|
||||
ok = r1.ok;
|
||||
data = ok ? await r1.json() : [];
|
||||
tokenEvents = r2.ok ? await r2.json() : [];
|
||||
} catch {}
|
||||
failures = ok ? 0 : failures + 1;
|
||||
yield {data, tokenEvents, ok, ts: new Date()};
|
||||
await new Promise(res => setTimeout(res, POLL));
|
||||
await sleep(pollDelay({ok, base: POLL_HEAVY, failures}));
|
||||
}
|
||||
})();
|
||||
```
|
||||
|
||||
@@ -3,19 +3,20 @@ title: Tasks
|
||||
---
|
||||
|
||||
```js
|
||||
import {API, POLL} from "./components/config.js";
|
||||
import {API, POLL_HEAVY, apiFetch, pollDelay, sleep} from "./components/config.js";
|
||||
```
|
||||
|
||||
```js
|
||||
const taskState = (async function*() {
|
||||
let failures = 0;
|
||||
while (true) {
|
||||
let data = [], ok = false;
|
||||
try {
|
||||
const [rt, rw, rto, rr] = await Promise.all([
|
||||
fetch(`${API}/tasks/?limit=500`),
|
||||
fetch(`${API}/workstreams/`),
|
||||
fetch(`${API}/topics/`),
|
||||
fetch(`${API}/repos/`),
|
||||
apiFetch("/tasks/?limit=500"),
|
||||
apiFetch("/workstreams/"),
|
||||
apiFetch("/topics/"),
|
||||
apiFetch("/repos/"),
|
||||
]);
|
||||
ok = rt.ok && rw.ok && rto.ok && rr.ok;
|
||||
if (ok) {
|
||||
@@ -33,8 +34,9 @@ const taskState = (async function*() {
|
||||
}));
|
||||
}
|
||||
} catch {}
|
||||
failures = ok ? 0 : failures + 1;
|
||||
yield {data, ok, ts: new Date()};
|
||||
await new Promise(res => setTimeout(res, POLL));
|
||||
await sleep(pollDelay({ok, base: POLL_HEAVY, failures}));
|
||||
}
|
||||
})();
|
||||
```
|
||||
|
||||
@@ -3,19 +3,20 @@ title: Technical Debt
|
||||
---
|
||||
|
||||
```js
|
||||
import {API, POLL} from "./components/config.js";
|
||||
import {API, POLL_HEAVY, apiFetch, pollDelay, sleep} from "./components/config.js";
|
||||
```
|
||||
|
||||
```js
|
||||
const tdState = (async function*() {
|
||||
let failures = 0;
|
||||
while (true) {
|
||||
let data = [], ok = false;
|
||||
try {
|
||||
const [rt, rw, rto, rr] = await Promise.all([
|
||||
fetch(`${API}/technical-debt/`),
|
||||
fetch(`${API}/workstreams/`),
|
||||
fetch(`${API}/topics/`),
|
||||
fetch(`${API}/repos/`),
|
||||
apiFetch("/technical-debt/"),
|
||||
apiFetch("/workstreams/"),
|
||||
apiFetch("/topics/"),
|
||||
apiFetch("/repos/"),
|
||||
]);
|
||||
ok = rt.ok && rw.ok && rto.ok && rr.ok;
|
||||
if (ok) {
|
||||
@@ -36,8 +37,9 @@ const tdState = (async function*() {
|
||||
});
|
||||
}
|
||||
} catch {}
|
||||
failures = ok ? 0 : failures + 1;
|
||||
yield {data, ok, ts: new Date()};
|
||||
await new Promise(res => setTimeout(res, POLL));
|
||||
await sleep(pollDelay({ok, base: POLL_HEAVY, failures}));
|
||||
}
|
||||
})();
|
||||
```
|
||||
|
||||
@@ -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}));
|
||||
}
|
||||
})();
|
||||
```
|
||||
|
||||
@@ -3,7 +3,7 @@ title: Token Cost
|
||||
---
|
||||
|
||||
```js
|
||||
import {API} from "./components/config.js";
|
||||
import {apiFetch, pollDelay, sleep} from "./components/config.js";
|
||||
import {refCell} from "./components/ref-cell.js";
|
||||
const POLL = 60_000;
|
||||
```
|
||||
@@ -11,14 +11,15 @@ const POLL = 60_000;
|
||||
```js
|
||||
// Fetch token events, by-repo summary, workstreams, and tasks in parallel
|
||||
const tokenState = (async function*() {
|
||||
let failures = 0;
|
||||
while (true) {
|
||||
let byRepo = [], events = [], wsMap = {}, taskMap = {}, ok = false;
|
||||
try {
|
||||
const [r1, r2, r3, r4] = await Promise.all([
|
||||
fetch(`${API}/token-events/by-repo/`),
|
||||
fetch(`${API}/token-events/?limit=1000`),
|
||||
fetch(`${API}/workstreams/`),
|
||||
fetch(`${API}/tasks/`),
|
||||
apiFetch("/token-events/by-repo/"),
|
||||
apiFetch("/token-events/?limit=1000"),
|
||||
apiFetch("/workstreams/"),
|
||||
apiFetch("/tasks/"),
|
||||
]);
|
||||
ok = r1.ok && r2.ok;
|
||||
if (ok) {
|
||||
@@ -34,8 +35,9 @@ const tokenState = (async function*() {
|
||||
for (const t of taskList) taskMap[t.id] = t;
|
||||
}
|
||||
} catch {}
|
||||
failures = ok ? 0 : failures + 1;
|
||||
yield {byRepo, events, wsMap, taskMap, ok, ts: new Date()};
|
||||
await new Promise(res => setTimeout(res, POLL));
|
||||
await sleep(pollDelay({ok, base: POLL, failures}));
|
||||
}
|
||||
})();
|
||||
```
|
||||
|
||||
@@ -3,7 +3,7 @@ title: UI Feedback
|
||||
---
|
||||
|
||||
```js
|
||||
import {API, POLL} from "./components/config.js";
|
||||
import {API, POLL_HEAVY, apiFetch, pollDelay, sleep} from "./components/config.js";
|
||||
```
|
||||
|
||||
```js
|
||||
@@ -47,10 +47,11 @@ function nextStep(current) {
|
||||
|
||||
```js
|
||||
const feedbackState = (async function*() {
|
||||
let failures = 0;
|
||||
while (true) {
|
||||
let data = [], ok = false;
|
||||
try {
|
||||
const r = await fetch(`${API}/technical-debt/?debt_type=dashboard-improvement`);
|
||||
const r = await apiFetch("/technical-debt/?debt_type=dashboard-improvement");
|
||||
ok = r.ok;
|
||||
if (ok) {
|
||||
const items = await r.json();
|
||||
@@ -62,8 +63,9 @@ const feedbackState = (async function*() {
|
||||
});
|
||||
}
|
||||
} catch {}
|
||||
failures = ok ? 0 : failures + 1;
|
||||
yield {data, ok, ts: new Date()};
|
||||
await new Promise(res => setTimeout(res, POLL));
|
||||
await sleep(pollDelay({ok, base: POLL_HEAVY, failures}));
|
||||
}
|
||||
})();
|
||||
```
|
||||
|
||||
@@ -3,20 +3,21 @@ title: Workstreams
|
||||
---
|
||||
|
||||
```js
|
||||
import {API, POLL} from "./components/config.js";
|
||||
import {API, POLL_HEAVY, apiFetch, pollDelay, sleep} from "./components/config.js";
|
||||
```
|
||||
|
||||
```js
|
||||
// Fetch workstreams + topics + summary (for dep graph) in parallel
|
||||
const wsState = (async function*() {
|
||||
let failures = 0;
|
||||
while (true) {
|
||||
let data = [], openWs = [], ok = false;
|
||||
try {
|
||||
const [rw, rt, rr, rs] = await Promise.all([
|
||||
fetch(`${API}/workstreams/`),
|
||||
fetch(`${API}/topics/`),
|
||||
fetch(`${API}/repos/`),
|
||||
fetch(`${API}/state/summary`),
|
||||
apiFetch("/workstreams/"),
|
||||
apiFetch("/topics/"),
|
||||
apiFetch("/repos/"),
|
||||
apiFetch("/state/summary", {timeout: 20_000}),
|
||||
]);
|
||||
ok = rw.ok && rt.ok && rr.ok && rs.ok;
|
||||
if (ok) {
|
||||
@@ -32,8 +33,9 @@ const wsState = (async function*() {
|
||||
openWs = summary.open_workstreams ?? [];
|
||||
}
|
||||
} catch {}
|
||||
failures = ok ? 0 : failures + 1;
|
||||
yield {data, openWs, 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