feat: ticker symbol voting for live votes
- Add ticker column to games table with migration - Bootstrap tickers from tickers.json config on startup - POST /api/votes/live accepts optional ticker field for direct game lookup (bypasses timestamp-interval matching) - Ticker votes work for any game, not just session games - Update API docs and add e2e tests for ticker voting - Version bump to 0.6.5 Made-with: Cursor
This commit is contained in:
29
backend/bootstrap.js
vendored
29
backend/bootstrap.js
vendored
@@ -54,6 +54,33 @@ function bootstrapGames() {
|
||||
console.log(`Successfully imported ${records.length} games from CSV`);
|
||||
}
|
||||
|
||||
function bootstrapTickers() {
|
||||
const tickersPath = path.join(__dirname, 'config', 'tickers.json');
|
||||
|
||||
if (!fs.existsSync(tickersPath)) {
|
||||
console.log('tickers.json not found. Skipping ticker bootstrap.');
|
||||
return;
|
||||
}
|
||||
|
||||
const tickers = JSON.parse(fs.readFileSync(tickersPath, 'utf-8'));
|
||||
|
||||
const update = db.prepare('UPDATE games SET ticker = ? WHERE title = ? AND (ticker IS NULL OR ticker != ?)');
|
||||
|
||||
const updateMany = db.transaction((entries) => {
|
||||
let updated = 0;
|
||||
for (const [symbol, title] of entries) {
|
||||
const result = update.run(symbol, title, symbol);
|
||||
updated += result.changes;
|
||||
}
|
||||
return updated;
|
||||
});
|
||||
|
||||
const updated = updateMany(Object.entries(tickers));
|
||||
if (updated > 0) {
|
||||
console.log(`Updated ticker symbols for ${updated} games`);
|
||||
}
|
||||
}
|
||||
|
||||
function parseLengthMinutes(lengthStr) {
|
||||
if (!lengthStr || lengthStr === '????' || lengthStr === '?') {
|
||||
return null;
|
||||
@@ -69,5 +96,5 @@ function parseBoolean(value) {
|
||||
return value.toLowerCase() === 'yes' ? 1 : 0;
|
||||
}
|
||||
|
||||
module.exports = { bootstrapGames };
|
||||
module.exports = { bootstrapGames, bootstrapTickers };
|
||||
|
||||
|
||||
Reference in New Issue
Block a user