fix(matchService): handle missing match after update with HttpError

- Added error handling in MatchService to throw an HttpError if a match is not found after an update, improving robustness.
- Enhanced sorting logic in DiaryView to ensure case-insensitive comparison for first and last names, with a stable fallback using IDs.
- Refactored currentClub watcher in ScheduleView to use an object syntax for better clarity and immediate execution on initialization.
This commit is contained in:
Torsten Schulz (local)
2026-02-27 12:00:23 +01:00
parent b3bbca3887
commit b2017b7365
3 changed files with 41 additions and 19 deletions

View File

@@ -12,6 +12,7 @@ import Club from '../models/Club.js';
import SeasonService from './seasonService.js';
import { checkAccess } from '../utils/userUtils.js';
import { Op } from 'sequelize';
import HttpError from '../exceptions/HttpError.js';
import { devLog } from '../utils/logger.js';
class MatchService {
@@ -470,6 +471,9 @@ class MatchService {
// Aktualisiertes Match nochmals laden und für WebSocket-Broadcast anreichern (gleiche Struktur wie getMatchesForLeague)
const updated = await Match.findByPk(matchId);
if (!updated) {
throw new HttpError('Match not found after update', 404);
}
const enriched = {
id: updated.id,
date: updated.date,