diff --git a/backend/services/matchService.js b/backend/services/matchService.js index 3655be9..2d32001 100644 --- a/backend/services/matchService.js +++ b/backend/services/matchService.js @@ -291,8 +291,6 @@ class MatchService { } const clubName = club.name; - devLog(`Filtering matches for club: ${clubName}`); - // Find all club teams in this league const clubTeams = await ClubTeam.findAll({ where: { @@ -302,8 +300,6 @@ class MatchService { attributes: ['id', 'name'] }); - devLog(`Club teams in league ${leagueId}: ${clubTeams.map(ct => ct.name).join(', ')}`); - // Find all Team entries that contain our club name const ownTeams = await Team.findAll({ where: { @@ -316,7 +312,6 @@ class MatchService { }); const ownTeamIds = ownTeams.map(t => t.id); - devLog(`Own team IDs in this league: ${ownTeamIds.join(', ')} (${ownTeams.map(t => t.name).join(', ')})`); // Load matches let matches; @@ -331,10 +326,8 @@ class MatchService { ] } }); - devLog(`Found ${matches.length} matches for our teams`); } else { // No own teams found - show nothing - devLog('No own teams found in this league, showing no matches'); matches = []; } diff --git a/backend/services/predefinedActivityService.js b/backend/services/predefinedActivityService.js index 24ddb74..69d09e9 100644 --- a/backend/services/predefinedActivityService.js +++ b/backend/services/predefinedActivityService.js @@ -58,20 +58,40 @@ class PredefinedActivityService { if (!q || q.length < 2) { return []; } - return await PredefinedActivity.findAll({ + + // Intelligente Suche: Teile den Query in einzelne Begriffe auf + const searchTerms = q.split(/\s+/).filter(term => term.length > 0); + + if (searchTerms.length === 0) { + return []; + } + + // Hole alle Aktivitäten mit Kürzeln + const allActivities = await PredefinedActivity.findAll({ where: { - [Op.or]: [ - { name: { [Op.like]: `%${q}%` } }, - { code: { [Op.like]: `%${q}%` } }, - ], + code: { [Op.ne]: null } // Nur Aktivitäten mit Kürzel }, order: [ [sequelize.literal('code IS NULL'), 'ASC'], ['code', 'ASC'], ['name', 'ASC'], ], - limit: Math.min(parseInt(limit || 20, 10), 50), + limit: 1000 // Höhere Grenze für Filterung }); + + // Filtere die Ergebnisse, um nur die zu finden, die ALLE Begriffe enthalten + const filteredResults = allActivities.filter(activity => { + const code = (activity.code || '').toLowerCase(); + + // Prüfe, ob alle Suchbegriffe im Kürzel enthalten sind + return searchTerms.every(term => { + const normalizedTerm = term.toLowerCase(); + return code.includes(normalizedTerm); + }); + }); + + // Begrenze die Ergebnisse + return filteredResults.slice(0, Math.min(parseInt(limit || 20, 10), 50)); } async mergeActivities(sourceId, targetId) { diff --git a/frontend/src/views/PredefinedActivities.vue b/frontend/src/views/PredefinedActivities.vue index 1f9ef45..ede7a25 100644 --- a/frontend/src/views/PredefinedActivities.vue +++ b/frontend/src/views/PredefinedActivities.vue @@ -6,10 +6,20 @@
-
+
+
+ + +
-
-