Display approved runs count in hero

Replace the previous "last slot" display with an approved runs counter. Renamed the DOM variable to approvedRunsEl, added renderApprovedRuns to compute and render the number of runs whose status is "approved" (case-insensitive), and wired it to loadRuns() and onRunsUpdate(). Also updated the hero label in index.html from "Current last ranked slot" to "Approved runs". Handles missing elements and empty responses safely.
This commit is contained in:
miles committed 2026-03-31 22:55:42 -05:00
1 parent 06c6beb0b1
commit 9d8906e94c
2 files changed
+12 -4

No files matched your search

+11 -3
View File
@@ -192,7 +192,7 @@
if(page==='index'){ if(page==='index'){
const totalEl = qs('hero-total-levels'); const totalEl = qs('hero-total-levels');
const topEl = qs('hero-top-entry'); const topEl = qs('hero-top-entry');
const lastEl = qs('hero-last-slot'); const approvedRunsEl = qs('hero-last-slot');
const featuredListEl = qs('featured-list'); const featuredListEl = qs('featured-list');
function renderFeatured(items){ function renderFeatured(items){
@@ -222,20 +222,28 @@
function renderHome(items){ function renderHome(items){
const rankedItems = items.slice().sort((a,b)=>(Number(a.position)||0)-(Number(b.position)||0)); const rankedItems = items.slice().sort((a,b)=>(Number(a.position)||0)-(Number(b.position)||0));
const firstItem = rankedItems[0]; const firstItem = rankedItems[0];
const lastItem = rankedItems[rankedItems.length - 1];
if(totalEl) totalEl.textContent = String(rankedItems.length || 0); if(totalEl) totalEl.textContent = String(rankedItems.length || 0);
if(topEl) topEl.textContent = firstItem ? firstItem.title : 'Unavailable'; if(topEl) topEl.textContent = firstItem ? firstItem.title : 'Unavailable';
if(lastEl) lastEl.textContent = lastItem && lastItem.position ? `#${lastItem.position}` : '--';
renderFeatured(rankedItems); renderFeatured(rankedItems);
} }
function renderApprovedRuns(runs){
if(!approvedRunsEl) return;
const approvedCount = runs.filter(run=>String(run.status || '').toLowerCase() === 'approved').length;
approvedRunsEl.textContent = String(approvedCount);
}
loadItems().then(renderHome).catch(()=>{ loadItems().then(renderHome).catch(()=>{
renderHome([]); renderHome([]);
}); });
loadRuns().then(renderApprovedRuns).catch(()=>{
renderApprovedRuns([]);
});
bindLiveUpdates(); bindLiveUpdates();
onLiveUpdate(renderHome); onLiveUpdate(renderHome);
onRunsUpdate(renderApprovedRuns);
} }
if(page==='roulette'){ if(page==='roulette'){
+1 -1
View File
@@ -43,7 +43,7 @@
</article> </article>
<article class="stat-card"> <article class="stat-card">
<strong id="hero-last-slot">--</strong> <strong id="hero-last-slot">--</strong>
<span>Current last ranked slot</span> <span>Approved runs</span>
</article> </article>
</div> </div>
</div> </div>