mirror of
https://github.com/itsnaveenk/bazar3.git
synced 2025-12-19 19:37:06 +00:00
Merge branch 'main' of https://github.com/itsnaveenk/bazar3
This commit is contained in:
commit
a01d1d9549
@ -10,6 +10,13 @@ const teamRoutes = require('./routes/team');
|
||||
|
||||
const app = express();
|
||||
|
||||
// Clear cache for all admin routes
|
||||
app.use('/admin', (req, res, next) => {
|
||||
console.log('Clearing cache for admin API hit...');
|
||||
cache.store.clear();
|
||||
next();
|
||||
});
|
||||
|
||||
app.use(cors({ origin: ['http://localhost:3000', '*', 'https://your-production-domain.com'] }));
|
||||
app.use(express.json({ limit: '10kb' }));
|
||||
app.use(security.anonymizeIP);
|
||||
|
||||
@ -39,10 +39,13 @@ exports.getTodayResults = async () => {
|
||||
const today = new Date().toISOString().split('T')[0];
|
||||
const cacheKey = `today:${today}`;
|
||||
|
||||
console.log(`Cache key: ${cacheKey}`);
|
||||
if (cache.has(cacheKey)) {
|
||||
console.log('Cache hit for today\'s results.');
|
||||
return cache.get(cacheKey);
|
||||
}
|
||||
|
||||
console.log('Cache miss. Fetching results from the database...');
|
||||
const results = await db.query(`
|
||||
SELECT t.name AS team, r.result_time,
|
||||
CASE
|
||||
@ -54,6 +57,7 @@ exports.getTodayResults = async () => {
|
||||
WHERE DATE(r.result_time) = ?
|
||||
`, [today]);
|
||||
|
||||
console.log('Caching today\'s results...');
|
||||
cache.set(cacheKey, results);
|
||||
return results;
|
||||
};
|
||||
@ -76,7 +80,7 @@ exports.getMonthlyResults = async (team, month) => {
|
||||
}
|
||||
|
||||
const results = await db.query(`
|
||||
SELECT r.result, r.result_time,
|
||||
SELECT r.result_time,
|
||||
CASE
|
||||
WHEN NOW() < r.result_time THEN '-1'
|
||||
ELSE r.result
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user