feat(Scheduler, MatchService, PredefinedActivity): enhance scheduling and match fetching features
- Added new scheduler routes to manage scheduling functionalities. - Updated match fetching logic to include a scope parameter for more flexible data retrieval. - Introduced a new field `excludeFromStats` in the PredefinedActivity model to manage activity visibility in statistics. - Enhanced the diary date activity controller to handle predefined activities, improving activity management. - Refactored various services to support new features and improve overall data handling.
This commit is contained in:
38
backend/routes/schedulerRoutes.js
Normal file
38
backend/routes/schedulerRoutes.js
Normal file
@@ -0,0 +1,38 @@
|
||||
import express from 'express';
|
||||
import { authenticate } from '../middleware/authMiddleware.js';
|
||||
import schedulerService from '../services/schedulerService.js';
|
||||
|
||||
const router = express.Router();
|
||||
|
||||
router.post('/rating_updates', authenticate, async (req, res) => {
|
||||
try {
|
||||
const result = await schedulerService.triggerRatingUpdates();
|
||||
res.json(result);
|
||||
} catch (error) {
|
||||
res.status(500).json({ success: false, message: error.message });
|
||||
}
|
||||
});
|
||||
|
||||
router.post('/match_results', authenticate, async (req, res) => {
|
||||
try {
|
||||
const result = await schedulerService.triggerMatchResultsFetch({
|
||||
userId: req.user.id,
|
||||
clubTeamId: req.body?.clubTeamId ?? null,
|
||||
currentSeasonOnly: true
|
||||
});
|
||||
res.json(result);
|
||||
} catch (error) {
|
||||
res.status(500).json({ success: false, message: error.message });
|
||||
}
|
||||
});
|
||||
|
||||
router.get('/status', authenticate, (req, res) => {
|
||||
const status = schedulerService.getStatus();
|
||||
const nextRatingUpdate = schedulerService.getNextRatingUpdateTime();
|
||||
res.json({
|
||||
...status,
|
||||
nextRatingUpdate
|
||||
});
|
||||
});
|
||||
|
||||
export default router;
|
||||
@@ -1,38 +1,9 @@
|
||||
import express from 'express';
|
||||
import { authenticate } from '../middleware/authMiddleware.js';
|
||||
import sessionController from '../controllers/sessionController.js';
|
||||
import schedulerService from '../services/schedulerService.js';
|
||||
|
||||
const router = express.Router();
|
||||
|
||||
router.get('/status', authenticate, sessionController.checkSession);
|
||||
|
||||
// Manual trigger endpoints for testing
|
||||
router.post('/trigger-rating-updates', authenticate, async (req, res) => {
|
||||
try {
|
||||
const result = await schedulerService.triggerRatingUpdates();
|
||||
res.json(result);
|
||||
} catch (error) {
|
||||
res.status(500).json({ success: false, message: error.message });
|
||||
}
|
||||
});
|
||||
|
||||
router.post('/trigger-match-fetch', authenticate, async (req, res) => {
|
||||
try {
|
||||
const result = await schedulerService.triggerMatchResultsFetch();
|
||||
res.json(result);
|
||||
} catch (error) {
|
||||
res.status(500).json({ success: false, message: error.message });
|
||||
}
|
||||
});
|
||||
|
||||
router.get('/scheduler-status', authenticate, (req, res) => {
|
||||
const status = schedulerService.getStatus();
|
||||
const nextRatingUpdate = schedulerService.getNextRatingUpdateTime();
|
||||
res.json({
|
||||
...status,
|
||||
nextRatingUpdate
|
||||
});
|
||||
});
|
||||
|
||||
export default router;
|
||||
|
||||
Reference in New Issue
Block a user