Refactor match and predefined activity services for improved functionality and user experience
Removed unnecessary logging from the MatchService to streamline performance. Enhanced the PredefinedActivityService by implementing a more intelligent search feature that splits queries into individual terms, allowing for more precise filtering of activities. Updated the frontend PredefinedActivities.vue to include a search input with real-time results and a clear search button, improving user interaction and accessibility.
This commit is contained in:
@@ -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 = [];
|
||||
}
|
||||
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user