refactor: route remaining fetch() calls through data/ modules
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:
@@ -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 };
|
||||
|
||||
Reference in New Issue
Block a user