chore: remove dead code orphaned by topbar redesign (#4)
The new topbar's "Refresh all" button replaces the old SSE-driven "Load All" link and progress UI. With those gone, several pieces of infrastructure had no callers left: - GET /api/load-all-players, POST /api/populate-database, and GET /api/database-status — SSE endpoints with no frontend consumers - #progress-section / #loading divs in players + courses pages - .progress-container / .progress-bar / .progress-text / .loading CSS - public/js/progress.js script (defines fetchRatingsWithProgress, never called, and loadAllPlayers, no longer wired) — to be deleted manually since the sandbox blocks rm
This commit is contained in:
@@ -12,37 +12,6 @@
|
|||||||
background: #059669;
|
background: #059669;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ── Progress ─────────────────────────────────── */
|
|
||||||
|
|
||||||
.progress-container {
|
|
||||||
width: 100%;
|
|
||||||
background: var(--surface-3);
|
|
||||||
border-radius: var(--radius-xl);
|
|
||||||
padding: 3px;
|
|
||||||
margin: 20px 0;
|
|
||||||
overflow: hidden;
|
|
||||||
}
|
|
||||||
|
|
||||||
.progress-bar {
|
|
||||||
width: 0%;
|
|
||||||
height: 26px;
|
|
||||||
background: linear-gradient(135deg, var(--accent), var(--accent-hover));
|
|
||||||
border-radius: var(--radius-xl);
|
|
||||||
text-align: center;
|
|
||||||
line-height: 26px;
|
|
||||||
color: white;
|
|
||||||
font-weight: 600;
|
|
||||||
font-size: 12px;
|
|
||||||
transition: width 0.4s ease;
|
|
||||||
}
|
|
||||||
|
|
||||||
.progress-text {
|
|
||||||
text-align: center;
|
|
||||||
margin: 8px 0;
|
|
||||||
font-size: 13px;
|
|
||||||
color: var(--text-secondary);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ── Mobile helpers ───────────────────────────── */
|
/* ── Mobile helpers ───────────────────────────── */
|
||||||
|
|
||||||
.mobile-only {
|
.mobile-only {
|
||||||
|
|||||||
@@ -306,15 +306,6 @@ body {
|
|||||||
margin: 0 0 24px 0;
|
margin: 0 0 24px 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ── Loading ──────────────────────────────────── */
|
|
||||||
|
|
||||||
.loading {
|
|
||||||
text-align: center;
|
|
||||||
padding: 40px 20px;
|
|
||||||
font-size: 15px;
|
|
||||||
color: var(--text-secondary);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ── Tables ───────────────────────────────────── */
|
/* ── Tables ───────────────────────────────────── */
|
||||||
|
|
||||||
table {
|
table {
|
||||||
|
|||||||
@@ -106,75 +106,6 @@ router.get('/api/ratings/progress', (req, res) => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
router.post('/api/populate-database', (req, res) => {
|
|
||||||
res.writeHead(200, {
|
|
||||||
'Content-Type': 'text/event-stream',
|
|
||||||
'Cache-Control': 'no-cache',
|
|
||||||
'Connection': 'keep-alive',
|
|
||||||
'Access-Control-Allow-Origin': '*',
|
|
||||||
});
|
|
||||||
|
|
||||||
const progressCallback = (progress) => {
|
|
||||||
res.write(`data: ${JSON.stringify(progress)}\n\n`);
|
|
||||||
};
|
|
||||||
|
|
||||||
logger.info('=== Starting database population from database players ===');
|
|
||||||
|
|
||||||
refreshAllPlayersInDB(progressCallback).then(ratings => {
|
|
||||||
logger.info(`=== Database population complete: ${ratings.length} players refreshed ===`);
|
|
||||||
res.write(`data: ${JSON.stringify({ status: 'complete', ratings, message: `Successfully refreshed ${ratings.length} players` })}\n\n`);
|
|
||||||
res.end();
|
|
||||||
}).catch(error => {
|
|
||||||
logger.error('Error populating database:', error);
|
|
||||||
res.write(`data: ${JSON.stringify({ status: 'error', message: error.message })}\n\n`);
|
|
||||||
res.end();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
router.get('/api/database-status', async (req, res) => {
|
|
||||||
try {
|
|
||||||
const playerCount = await new Promise((resolve, reject) => {
|
|
||||||
db.get('SELECT COUNT(*) as count FROM players', [], (err, row) => {
|
|
||||||
if (err) reject(err);
|
|
||||||
else resolve(row.count);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
res.json({
|
|
||||||
playersInDB: playerCount,
|
|
||||||
needsPopulation: playerCount === 0
|
|
||||||
});
|
|
||||||
} catch (error) {
|
|
||||||
res.status(500).json({ error: 'Failed to check database status' });
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
router.get('/api/load-all-players', (req, res) => {
|
|
||||||
res.writeHead(200, {
|
|
||||||
'Content-Type': 'text/event-stream',
|
|
||||||
'Cache-Control': 'no-cache',
|
|
||||||
'Connection': 'keep-alive',
|
|
||||||
'Access-Control-Allow-Origin': '*',
|
|
||||||
'Access-Control-Allow-Headers': 'Cache-Control'
|
|
||||||
});
|
|
||||||
|
|
||||||
const progressCallback = (progress) => {
|
|
||||||
res.write(`data: ${JSON.stringify(progress)}\n\n`);
|
|
||||||
};
|
|
||||||
|
|
||||||
refreshAllPlayersInDB(progressCallback).then(ratings => {
|
|
||||||
res.write(`data: ${JSON.stringify({ status: 'complete', ratings })}\n\n`);
|
|
||||||
res.end();
|
|
||||||
}).catch(error => {
|
|
||||||
res.write(`data: ${JSON.stringify({ status: 'error', error: error.message })}\n\n`);
|
|
||||||
res.end();
|
|
||||||
});
|
|
||||||
|
|
||||||
req.on('close', () => {
|
|
||||||
res.end();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
router.get('/api/rating-history/:pdgaNumber', async (req, res) => {
|
router.get('/api/rating-history/:pdgaNumber', async (req, res) => {
|
||||||
try {
|
try {
|
||||||
const { pdgaNumber } = req.params;
|
const { pdgaNumber } = req.params;
|
||||||
|
|||||||
@@ -19,7 +19,6 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="loading" class="loading" style="display: none;">Loading courses...</div>
|
|
||||||
<div id="courses-table" hx-get="/partials/course-table" hx-trigger="load"></div>
|
<div id="courses-table" hx-get="/partials/course-table" hx-trigger="load"></div>
|
||||||
`; %>
|
`; %>
|
||||||
|
|
||||||
|
|||||||
@@ -19,13 +19,6 @@
|
|||||||
<div style="display: flex; justify-content: flex-end; gap: 12px; margin-bottom: 16px;">
|
<div style="display: flex; justify-content: flex-end; gap: 12px; margin-bottom: 16px;">
|
||||||
<a href="#" onclick="clearCache(); return false;" style="color: var(--text-muted); font-size: 12px; text-decoration: none; opacity: 0.4;" title="Clear cache"><i class="fas fa-cog"></i></a>
|
<a href="#" onclick="clearCache(); return false;" style="color: var(--text-muted); font-size: 12px; text-decoration: none; opacity: 0.4;" title="Clear cache"><i class="fas fa-cog"></i></a>
|
||||||
</div>
|
</div>
|
||||||
<div id="loading" class="loading" style="display: none;">Loading ratings...</div>
|
|
||||||
<div id="progress-section" style="display: none;">
|
|
||||||
<div class="progress-container">
|
|
||||||
<div id="progress-bar" class="progress-bar">0%</div>
|
|
||||||
</div>
|
|
||||||
<div id="progress-text" class="progress-text">Preparing to load ratings...</div>
|
|
||||||
</div>
|
|
||||||
<div id="ratings-table" hx-get="/partials/ratings-table" hx-trigger="load"></div>
|
<div id="ratings-table" hx-get="/partials/ratings-table" hx-trigger="load"></div>
|
||||||
`; %>
|
`; %>
|
||||||
|
|
||||||
@@ -57,7 +50,7 @@
|
|||||||
title: 'PDGA Ratings',
|
title: 'PDGA Ratings',
|
||||||
activePage: 'players',
|
activePage: 'players',
|
||||||
cssFiles: ['players.css'],
|
cssFiles: ['players.css'],
|
||||||
jsFiles: ['tooltips.js', 'chart.js', 'progress.js', 'players.js'],
|
jsFiles: ['tooltips.js', 'chart.js', 'players.js'],
|
||||||
initScript: 'setupTooltipsAfterSwap();',
|
initScript: 'setupTooltipsAfterSwap();',
|
||||||
body: body,
|
body: body,
|
||||||
modals: modals
|
modals: modals
|
||||||
|
|||||||
Reference in New Issue
Block a user