refactor: route remaining fetch() calls through data/ modules
Some checks failed
CI / validate (pull_request) Failing after 13s
CI / auto-merge (pull_request) Has been skipped

bookshelves.js used direct Gitea API fetch() for commit banners and
PR bookshelves. weather.js used direct Open-Meteo fetch() for weather.
Route both through their respective data/ modules (data/gitea.js and
data/weather.js). Add fetchMergedPRs() to data/gitea.js.

The one remaining fetch() in weather.js (runPortalHealthChecks) is a
no-cors connectivity probe, not data collection — accepted exception.

Fixes #421

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Alexander Whitestone
2026-03-24 18:06:28 -04:00
parent 764b617a2a
commit 3c961beefd
3 changed files with 41 additions and 53 deletions

View File

@@ -139,4 +139,25 @@ export async function refreshAgentData() {
}
}
export async function fetchMergedPRs(limit = 20) {
try {
const res = await fetch(
`${GITEA_BASE}/repos/Timmy_Foundation/the-nexus/pulls?state=closed&limit=${limit}`,
{ headers: { 'Authorization': `token ${GITEA_TOKEN}` } }
);
if (!res.ok) return [];
const data = await res.json();
return data
.filter(p => p.merged)
.map(p => ({
prNum: p.number,
title: p.title
.replace(/^\[[\w\s]+\]\s*/i, '')
.replace(/\s*\(#\d+\)\s*$/, ''),
}));
} catch {
return [];
}
}
export { GITEA_BASE, GITEA_TOKEN, GITEA_REPOS, AGENT_NAMES, CACHE_MS as AGENT_STATUS_CACHE_MS };