feat(MatchService): enhance match filtering for own teams and update mobile app settings
All checks were successful
Deploy tt-tagebuch / deploy (push) Successful in 43s
All checks were successful
Deploy tt-tagebuch / deploy (push) Successful in 43s
- Added logic in MatchService to filter matches based on the user's own teams, ensuring only relevant matches are displayed. - Updated the mobile app's TODO list to reflect progress on ClubSettings and Predefined Activities features. - Enhanced the AppRoot and ClubStammdatenScreens to support new settings and permissions for club management. - Introduced new API methods for creating and updating training groups and times, improving the training management capabilities. - Refactored MembersManager to include methods for managing training groups and times, streamlining the member management process.
This commit is contained in:
@@ -211,6 +211,28 @@ class MatchService {
|
||||
throw new Error('Season not found');
|
||||
}
|
||||
}
|
||||
|
||||
// Nur Spiele mit eigener Mannschaft (gleiche Logik wie getMatchesForLeague mit scope "own"):
|
||||
// Mannschaften, deren Name mit dem Vereinsnamen beginnt, in Ligen dieser Saison.
|
||||
const club = await Club.findByPk(clubId, { attributes: ['name'] });
|
||||
const leaguesInSeason = await League.findAll({
|
||||
where: { clubId, seasonId: season.id },
|
||||
attributes: ['id']
|
||||
});
|
||||
const leagueIdList = leaguesInSeason.map((l) => l.id);
|
||||
let ownTeamIdSet = new Set();
|
||||
if (club?.name && leagueIdList.length) {
|
||||
const escaped = String(club.name).replace(/\\/g, '\\\\').replace(/%/g, '\\%').replace(/_/g, '\\_');
|
||||
const ownTeams = await Team.findAll({
|
||||
where: {
|
||||
leagueId: { [Op.in]: leagueIdList },
|
||||
name: { [Op.like]: `${escaped}%` }
|
||||
},
|
||||
attributes: ['id']
|
||||
});
|
||||
ownTeamIdSet = new Set(ownTeams.map((t) => t.id));
|
||||
}
|
||||
|
||||
const matches = await Match.findAll({
|
||||
where: {
|
||||
clubId: clubId,
|
||||
@@ -225,6 +247,13 @@ class MatchService {
|
||||
if (!league || league.seasonId !== season.id) {
|
||||
continue; // Skip matches from other seasons
|
||||
}
|
||||
|
||||
// Kalender: nur Punktspiele, an denen der Verein beteiligt ist (eigene Mannschaft Heim oder Gast)
|
||||
if (ownTeamIdSet.size > 0) {
|
||||
if (!ownTeamIdSet.has(match.homeTeamId) && !ownTeamIdSet.has(match.guestTeamId)) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
const enrichedMatch = {
|
||||
id: match.id,
|
||||
|
||||
Reference in New Issue
Block a user