Skip to content

Commit b88c8ca

Browse files
committed
fix: last updated time
1 parent 343e85c commit b88c8ca

1 file changed

Lines changed: 27 additions & 0 deletions

File tree

docs/script.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@ class TrainingDashboard {
6464
this.statusBadge.textContent = dataLoaded ? 'Data Loaded' : 'No Data';
6565
this.statusBadge.classList.toggle('error', !dataLoaded);
6666
}
67+
// Update last update time after loading metrics
68+
this.updateLastUpdateTime();
6769
} catch (err) {
6870
console.error('Init error:', err);
6971
this.failBadge('Data Load Error');
@@ -74,6 +76,31 @@ class TrainingDashboard {
7476
}, 3000);
7577
this.startAutoRefresh();
7678
}
79+
async updateLastUpdateTime() {
80+
// Try to get the last modified time of train_output.md (or test_output.md)
81+
const lastUpdateElem = document.getElementById('lastUpdate');
82+
if (!lastUpdateElem) return;
83+
try {
84+
// Use fetch HEAD to get last-modified header
85+
const resp = await fetch('train_output.md', { method: 'HEAD', cache: 'no-store' });
86+
let lastMod = resp.headers.get('last-modified');
87+
if (!lastMod) {
88+
// fallback: try test_output.md
89+
const resp2 = await fetch('test_output.md', { method: 'HEAD', cache: 'no-store' });
90+
lastMod = resp2.headers.get('last-modified');
91+
}
92+
if (lastMod) {
93+
const date = new Date(lastMod);
94+
// Format as YYYY-MM-DD HH:mm (local time)
95+
const fmt = date.getFullYear() + '-' + String(date.getMonth()+1).padStart(2,'0') + '-' + String(date.getDate()).padStart(2,'0') + ' ' + String(date.getHours()).padStart(2,'0') + ':' + String(date.getMinutes()).padStart(2,'0');
96+
lastUpdateElem.textContent = fmt;
97+
} else {
98+
lastUpdateElem.textContent = 'Unknown';
99+
}
100+
} catch (err) {
101+
lastUpdateElem.textContent = 'Unknown';
102+
}
103+
}
77104

78105
async fetchText(path) {
79106
const resp = await fetch(path, { cache: 'no-store' });

0 commit comments

Comments
 (0)