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:
Torsten Schulz (local)
2026-03-17 14:10:35 +01:00
parent f1cfd1147d
commit afe51f399c
53 changed files with 2846 additions and 926 deletions

View 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;

View File

@@ -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;