diff --git a/backend/cleanupKeysNode.cjs b/backend/cleanupKeysNode.cjs
index 279c213..f9d65ec 100644
--- a/backend/cleanupKeysNode.cjs
+++ b/backend/cleanupKeysNode.cjs
@@ -9,15 +9,18 @@ const dbConfig = {
database: process.env.DB_NAME || 'trainingsdiary'
};
+const report = [];
+
async function cleanupKeys() {
let connection;
try {
- console.log('🔌 Verbinde mit der Datenbank...');
+ report.push('🔌 Verbinde mit der Datenbank...');
connection = await mysql.createConnection(dbConfig);
// 1. Status vor dem Cleanup
- console.log('\n📊 STATUS VOR DEM CLEANUP:');
+ report.push('');
+ report.push('📊 STATUS VOR DEM CLEANUP:');
const [tablesBefore] = await connection.execute(`
SELECT
TABLE_NAME,
@@ -29,57 +32,60 @@ async function cleanupKeys() {
`, [dbConfig.database]);
tablesBefore.forEach(table => {
- console.log(` ${table.TABLE_NAME}: ${table.key_count} Keys`);
+ report.push(` ${table.TABLE_NAME}: ${table.key_count} Keys`);
});
// 2. Alle INDEX der Problem-Tabellen anzeigen
const problemTables = ['member', 'diary_tags', 'season'];
for (const tableName of problemTables) {
- console.log(`\n🔍 INDEX für Tabelle '${tableName}':`);
+ report.push('');
+ report.push(`🔍 INDEX für Tabelle '${tableName}':`);
try {
const [indexes] = await connection.execute(`SHOW INDEX FROM \`${tableName}\``);
if (indexes.length === 0) {
- console.log(` Keine INDEX gefunden für Tabelle '${tableName}'`);
+ report.push(` Keine INDEX gefunden für Tabelle '${tableName}'`);
continue;
}
indexes.forEach(index => {
- console.log(` - ${index.Key_name} (${index.Column_name}) - ${index.Non_unique === 0 ? 'UNIQUE' : 'NON-UNIQUE'}`);
+ report.push(` - ${index.Key_name} (${index.Column_name}) - ${index.Non_unique === 0 ? 'UNIQUE' : 'NON-UNIQUE'}`);
});
// 3. Überflüssige INDEX entfernen (alle außer PRIMARY und UNIQUE)
- console.log(`\n🗑️ Entferne überflüssige INDEX aus '${tableName}':`);
+ report.push('');
+ report.push(`🗑️ Entferne überflüssige INDEX aus '${tableName}':`);
for (const index of indexes) {
// Behalte PRIMARY KEY und UNIQUE constraints
if (index.Key_name === 'PRIMARY' || index.Non_unique === 0) {
- console.log(` ✅ Behalte: ${index.Key_name} (${index.Column_name})`);
+ report.push(` ✅ Behalte: ${index.Key_name} (${index.Column_name})`);
continue;
}
// Entferne alle anderen INDEX
try {
await connection.execute(`DROP INDEX \`${index.Key_name}\` ON \`${tableName}\``);
- console.log(` ❌ Entfernt: ${index.Key_name} (${index.Column_name})`);
+ report.push(` ❌ Entfernt: ${index.Key_name} (${index.Column_name})`);
} catch (error) {
if (error.code === 'ER_CANT_DROP_FIELD_OR_KEY') {
- console.log(` ⚠️ Kann nicht entfernen: ${index.Key_name} (${index.Column_name}) - ${error.message}`);
+ report.push(` ⚠️ Kann nicht entfernen: ${index.Key_name} (${index.Column_name}) - ${error.message}`);
} else {
- console.log(` ❌ Fehler beim Entfernen von ${index.Key_name}: ${error.message}`);
+ report.push(` ❌ Fehler beim Entfernen von ${index.Key_name}: ${error.message}`);
}
}
}
} catch (error) {
- console.log(` ⚠️ Fehler beim Zugriff auf Tabelle '${tableName}': ${error.message}`);
+ report.push(` ⚠️ Fehler beim Zugriff auf Tabelle '${tableName}': ${error.message}`);
}
}
// 4. Status nach dem Cleanup
- console.log('\n📊 STATUS NACH DEM CLEANUP:');
+ report.push('');
+ report.push('📊 STATUS NACH DEM CLEANUP:');
const [tablesAfter] = await connection.execute(`
SELECT
TABLE_NAME,
@@ -96,7 +102,7 @@ async function cleanupKeys() {
const diff = beforeCount - table.key_count;
const status = table.key_count <= 5 ? '✅' : table.key_count <= 10 ? '⚠️' : '❌';
- console.log(` ${status} ${table.TABLE_NAME}: ${table.key_count} Keys (${diff > 0 ? `-${diff}` : `+${Math.abs(diff)}`})`);
+ report.push(` ${status} ${table.TABLE_NAME}: ${table.key_count} Keys (${diff > 0 ? `-${diff}` : `+${Math.abs(diff)}`})`);
});
// 5. Gesamtanzahl der Keys
@@ -106,18 +112,20 @@ async function cleanupKeys() {
WHERE TABLE_SCHEMA = ?
`, [dbConfig.database]);
- console.log(`\n📈 GESAMTANZAHL KEYS: ${totalKeys[0].total_keys}`);
-
+ report.push('');
+ report.push(`📈 GESAMTANZAHL KEYS: ${totalKeys[0].total_keys}`);
+
// 6. Zusammenfassung
- console.log('\n🎯 ZUSAMMENFASSUNG:');
+ report.push('');
+ report.push('🎯 ZUSAMMENFASSUNG:');
const problemTablesAfter = tablesAfter.filter(t => t.key_count > 10);
if (problemTablesAfter.length === 0) {
- console.log(' ✅ Alle Tabellen haben jetzt weniger als 10 Keys!');
+ report.push(' ✅ Alle Tabellen haben jetzt weniger als 10 Keys!');
} else {
- console.log(' ⚠️ Folgende Tabellen haben immer noch zu viele Keys:');
+ report.push(' ⚠️ Folgende Tabellen haben immer noch zu viele Keys:');
problemTablesAfter.forEach(table => {
- console.log(` - ${table.TABLE_NAME}: ${table.key_count} Keys`);
+ report.push(` - ${table.TABLE_NAME}: ${table.key_count} Keys`);
});
}
@@ -126,15 +134,18 @@ async function cleanupKeys() {
} finally {
if (connection) {
await connection.end();
- console.log('\n🔌 Datenbankverbindung geschlossen.');
+ report.push('');
+ report.push('🔌 Datenbankverbindung geschlossen.');
}
}
}
// Script ausführen
-console.log('🚀 Starte intelligentes INDEX-Cleanup...\n');
+report.push('🚀 Starte intelligentes INDEX-Cleanup...');
cleanupKeys().then(() => {
- console.log('\n✨ Cleanup abgeschlossen!');
+ report.push('');
+ report.push('✨ Cleanup abgeschlossen!');
+ process.stdout.write(`${report.join('\n')}\n`);
process.exit(0);
}).catch(error => {
console.error('\n💥 Fehler beim Cleanup:', error);
diff --git a/backend/cleanupKeysNode.js b/backend/cleanupKeysNode.js
index 031a000..8783865 100644
--- a/backend/cleanupKeysNode.js
+++ b/backend/cleanupKeysNode.js
@@ -7,41 +7,23 @@ import { fileURLToPath } from 'url';
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
+const report = [];
+
// Umgebungsvariablen aus dem Root-Verzeichnis laden
-//const envPath = path.join(__dirname, '..', '.env');
-//console.log('🔍 Lade .env-Datei von:', envPath);
+const envPath = path.join(__dirname, '..', '.env');
dotenv.config();
-
-// Debug: Zeige geladene Umgebungsvariablen
-console.log('🔍 Geladene Umgebungsvariablen:');
-console.log(' DB_HOST:', process.env.DB_HOST);
-console.log(' DB_USER:', process.env.DB_USER);
-console.log(' DB_NAME:', process.env.DB_NAME);
-console.log(' DB_PASSWORD:', process.env.DB_PASSWORD ? '***gesetzt***' : 'nicht gesetzt');
-
-// Datenbankverbindung
-const dbConfig = {
- host: process.env.DB_HOST || 'localhost',
- user: process.env.DB_USER || 'root',
- password: process.env.DB_PASSWORD || '',
- database: process.env.DB_NAME || 'trainingsdiary'
-};
-
-console.log('🔍 Datenbankverbindung:');
-console.log(' Host:', dbConfig.host);
-console.log(' User:', dbConfig.user);
-console.log(' Database:', dbConfig.database);
-console.log(' Password:', dbConfig.password ? '***gesetzt***' : 'nicht gesetzt');
+report.push('Environment variables loaded');
async function cleanupKeys() {
let connection;
try {
- console.log('🔌 Verbinde mit der Datenbank...');
+ report.push('🔌 Verbinde mit der Datenbank...');
connection = await mysql.createConnection(dbConfig);
// 1. Status vor dem Cleanup
- console.log('\n📊 STATUS VOR DEM CLEANUP:');
+ report.push('');
+ report.push('📊 STATUS VOR DEM CLEANUP:');
const [tablesBefore] = await connection.execute(`
SELECT
TABLE_NAME,
@@ -53,57 +35,60 @@ async function cleanupKeys() {
`, [dbConfig.database]);
tablesBefore.forEach(table => {
- console.log(` ${table.TABLE_NAME}: ${table.key_count} Keys`);
+ report.push(` ${table.TABLE_NAME}: ${table.key_count} Keys`);
});
// 2. Alle INDEX der Problem-Tabellen anzeigen
const problemTables = ['member', 'diary_tags', 'season'];
for (const tableName of problemTables) {
- console.log(`\n🔍 INDEX für Tabelle '${tableName}':`);
+ report.push('');
+ report.push(`🔍 INDEX für Tabelle '${tableName}':`);
try {
const [indexes] = await connection.execute(`SHOW INDEX FROM \`${tableName}\``);
if (indexes.length === 0) {
- console.log(` Keine INDEX gefunden für Tabelle '${tableName}'`);
+ report.push(` Keine INDEX gefunden für Tabelle '${tableName}'`);
continue;
}
indexes.forEach(index => {
- console.log(` - ${index.Key_name} (${index.Column_name}) - ${index.Non_unique === 0 ? 'UNIQUE' : 'NON-UNIQUE'}`);
+ report.push(` - ${index.Key_name} (${index.Column_name}) - ${index.Non_unique === 0 ? 'UNIQUE' : 'NON-UNIQUE'}`);
});
// 3. Überflüssige INDEX entfernen (alle außer PRIMARY und UNIQUE)
- console.log(`\n🗑️ Entferne überflüssige INDEX aus '${tableName}':`);
+ report.push('');
+ report.push(`🗑️ Entferne überflüssige INDEX aus '${tableName}':`);
for (const index of indexes) {
// Behalte PRIMARY KEY und UNIQUE constraints
if (index.Key_name === 'PRIMARY' || index.Non_unique === 0) {
- console.log(` ✅ Behalte: ${index.Key_name} (${index.Column_name})`);
+ report.push(` ✅ Behalte: ${index.Key_name} (${index.Column_name})`);
continue;
}
// Entferne alle anderen INDEX
try {
await connection.execute(`DROP INDEX \`${index.Key_name}\` ON \`${tableName}\``);
- console.log(` ❌ Entfernt: ${index.Key_name} (${index.Column_name})`);
+ report.push(` ❌ Entfernt: ${index.Key_name} (${index.Column_name})`);
} catch (error) {
if (error.code === 'ER_CANT_DROP_FIELD_OR_KEY') {
- console.log(` ⚠️ Kann nicht entfernen: ${index.Key_name} (${index.Column_name}) - ${error.message}`);
+ report.push(` ⚠️ Kann nicht entfernen: ${index.Key_name} (${index.Column_name}) - ${error.message}`);
} else {
- console.log(` ❌ Fehler beim Entfernen von ${index.Key_name}: ${error.message}`);
+ report.push(` ❌ Fehler beim Entfernen von ${index.Key_name}: ${error.message}`);
}
}
}
} catch (error) {
- console.log(` ⚠️ Fehler beim Zugriff auf Tabelle '${tableName}': ${error.message}`);
+ report.push(` ⚠️ Fehler beim Zugriff auf Tabelle '${tableName}': ${error.message}`);
}
}
// 4. Status nach dem Cleanup
- console.log('\n📊 STATUS NACH DEM CLEANUP:');
+ report.push('');
+ report.push('📊 STATUS NACH DEM CLEANUP:');
const [tablesAfter] = await connection.execute(`
SELECT
TABLE_NAME,
@@ -120,7 +105,7 @@ async function cleanupKeys() {
const diff = beforeCount - table.key_count;
const status = table.key_count <= 5 ? '✅' : table.key_count <= 10 ? '⚠️' : '❌';
- console.log(` ${status} ${table.TABLE_NAME}: ${table.key_count} Keys (${diff > 0 ? `-${diff}` : `+${Math.abs(diff)}`})`);
+ report.push(` ${status} ${table.TABLE_NAME}: ${table.key_count} Keys (${diff > 0 ? `-${diff}` : `+${Math.abs(diff)}`})`);
});
// 5. Gesamtanzahl der Keys
@@ -130,18 +115,20 @@ async function cleanupKeys() {
WHERE TABLE_SCHEMA = ?
`, [dbConfig.database]);
- console.log(`\n📈 GESAMTANZAHL KEYS: ${totalKeys[0].total_keys}`);
+ report.push('');
+ report.push(`📈 GESAMTANZAHL KEYS: ${totalKeys[0].total_keys}`);
// 6. Zusammenfassung
- console.log('\n🎯 ZUSAMMENFASSUNG:');
+ report.push('');
+ report.push('🎯 ZUSAMMENFASSUNG:');
const problemTablesAfter = tablesAfter.filter(t => t.key_count > 10);
if (problemTablesAfter.length === 0) {
- console.log(' ✅ Alle Tabellen haben jetzt weniger als 10 Keys!');
+ report.push(' ✅ Alle Tabellen haben jetzt weniger als 10 Keys!');
} else {
- console.log(' ⚠️ Folgende Tabellen haben immer noch zu viele Keys:');
+ report.push(' ⚠️ Folgende Tabellen haben immer noch zu viele Keys:');
problemTablesAfter.forEach(table => {
- console.log(` - ${table.TABLE_NAME}: ${table.key_count} Keys`);
+ report.push(` - ${table.TABLE_NAME}: ${table.key_count} Keys`);
});
}
@@ -150,15 +137,18 @@ async function cleanupKeys() {
} finally {
if (connection) {
await connection.end();
- console.log('\n🔌 Datenbankverbindung geschlossen.');
+ report.push('');
+ report.push('🔌 Datenbankverbindung geschlossen.');
}
}
}
// Script ausführen
-console.log('🚀 Starte intelligentes INDEX-Cleanup...\n');
+report.push('🚀 Starte intelligentes INDEX-Cleanup...');
cleanupKeys().then(() => {
- console.log('\n✨ Cleanup abgeschlossen!');
+ report.push('');
+ report.push('✨ Cleanup abgeschlossen!');
+ process.stdout.write(`${report.join('\n')}\n`);
process.exit(0);
}).catch(error => {
console.error('\n💥 Fehler beim Cleanup:', error);
diff --git a/backend/clients/myTischtennisClient.js b/backend/clients/myTischtennisClient.js
index 9b2206c..1af6b69 100644
--- a/backend/clients/myTischtennisClient.js
+++ b/backend/clients/myTischtennisClient.js
@@ -156,17 +156,6 @@ class MyTischtennisClient {
if (result.success) {
- console.log('[getUserProfile] - Response structure:', {
- hasUserProfile: !!result.data?.userProfile,
- hasClub: !!result.data?.userProfile?.club,
- hasOrganization: !!result.data?.userProfile?.organization,
- clubnr: result.data?.userProfile?.club?.clubnr,
- clubName: result.data?.userProfile?.club?.name,
- orgShort: result.data?.userProfile?.organization?.short,
- ttr: result.data?.userProfile?.ttr,
- qttr: result.data?.userProfile?.qttr
- });
-
return {
success: true,
diff --git a/backend/controllers/diaryMemberActivityController.js b/backend/controllers/diaryMemberActivityController.js
index 41269fd..7f96a50 100644
--- a/backend/controllers/diaryMemberActivityController.js
+++ b/backend/controllers/diaryMemberActivityController.js
@@ -20,13 +20,6 @@ export const addMembersToActivity = async (req, res) => {
const { clubId, diaryDateActivityId } = req.params;
const { participantIds } = req.body; // array of participant ids
- console.log('[addMembersToActivity] Request:', {
- clubId,
- diaryDateActivityId,
- participantIds,
- bodyKeys: Object.keys(req.body)
- });
-
await checkAccess(userToken, clubId);
if (!participantIds || !Array.isArray(participantIds)) {
@@ -35,25 +28,20 @@ export const addMembersToActivity = async (req, res) => {
}
const validParticipants = await Participant.findAll({ where: { id: participantIds } });
- console.log('[addMembersToActivity] Valid participants found:', validParticipants.length);
const validIds = new Set(validParticipants.map(p => p.id));
const created = [];
for (const pid of participantIds) {
if (!validIds.has(pid)) {
- console.log('[addMembersToActivity] Participant not found:', pid);
continue;
}
const existing = await DiaryMemberActivity.findOne({ where: { diaryDateActivityId, participantId: pid } });
if (!existing) {
const rec = await DiaryMemberActivity.create({ diaryDateActivityId, participantId: pid });
- console.log('[addMembersToActivity] Created:', rec.id);
created.push(rec);
} else {
- console.log('[addMembersToActivity] Already exists:', pid);
}
}
- console.log('[addMembersToActivity] Success, created:', created.length);
res.status(201).json(created);
} catch (e) {
console.error('[addMembersToActivity] Error:', e);
diff --git a/backend/scripts/cleanupAllIndexes.js b/backend/scripts/cleanupAllIndexes.js
index 2e556f7..36c7569 100644
--- a/backend/scripts/cleanupAllIndexes.js
+++ b/backend/scripts/cleanupAllIndexes.js
@@ -3,6 +3,8 @@ import dotenv from 'dotenv';
dotenv.config();
+const report = [];
+
const dbConfig = {
host: process.env.DB_HOST || 'localhost',
user: process.env.DB_USER || 'root',
@@ -56,9 +58,9 @@ async function cleanupDuplicates(connection, table) {
for (const idxName of dropNames) {
try {
await connection.execute(`DROP INDEX \`${idxName}\` ON \`${table}\``);
- console.log(`[drop] ${table}: ${idxName}`);
+ report.push(`[drop] ${table}: ${idxName}`);
} catch (e) {
- console.warn(`[warn] ${table}: konnte Index ${idxName} nicht löschen: ${e.code || e.message}`);
+ report.push(`[warn] ${table}: konnte Index ${idxName} nicht löschen: ${e.code || e.message}`);
}
}
@@ -69,11 +71,11 @@ async function cleanupDuplicates(connection, table) {
async function main() {
let connection;
try {
- console.log('Connecting to DB:', dbConfig);
+ report.push(`Connecting to DB: ${JSON.stringify(dbConfig)}`);
connection = await mysql.createConnection(dbConfig);
const tables = await getTables(connection);
- console.log(`Found ${tables.length} tables`);
+ report.push(`Found ${tables.length} tables`);
let totalBefore = 0;
let totalAfter = 0;
@@ -86,12 +88,15 @@ async function main() {
totalDropped += dropped;
}
- console.log('Summary:', { totalBefore, totalAfter, totalDropped });
+ report.push(`Summary: ${JSON.stringify({ totalBefore, totalAfter, totalDropped })}`);
} catch (e) {
console.error('Cleanup failed:', e);
process.exitCode = 1;
} finally {
if (connection) await connection.end();
+ if (report.length > 0) {
+ process.stdout.write(`${report.join('\n')}\n`);
+ }
}
}
diff --git a/backend/scripts/cleanupUserTokenKeys.js b/backend/scripts/cleanupUserTokenKeys.js
index c822c59..c9dca1f 100644
--- a/backend/scripts/cleanupUserTokenKeys.js
+++ b/backend/scripts/cleanupUserTokenKeys.js
@@ -3,6 +3,8 @@ import dotenv from 'dotenv';
dotenv.config();
+const report = [];
+
const dbConfig = {
host: process.env.DB_HOST || 'localhost',
user: process.env.DB_USER || 'root',
@@ -26,13 +28,14 @@ async function cleanupUserTokenKeys() {
const table = 'UserToken';
try {
- console.log('Connecting to DB:', dbConfig);
+ report.push(`Connecting to DB: ${JSON.stringify(dbConfig)}`);
connection = await mysql.createConnection(dbConfig);
- console.log(`\nBefore cleanup (indexes on ${table}):`);
+ report.push('');
+ report.push(`Before cleanup (indexes on ${table}):`);
let before = await getIndexSummary(connection, table);
Object.entries(before).forEach(([name, info]) => {
- console.log(` - ${name} ${info.unique ? '(UNIQUE)' : ''} -> [${info.columns.join(', ')}]`);
+ report.push(` - ${name} ${info.unique ? '(UNIQUE)' : ''} -> [${info.columns.join(', ')}]`);
});
// Drop all non-PRIMARY indexes on UserToken
@@ -42,9 +45,9 @@ async function cleanupUserTokenKeys() {
for (const keyName of keyNames) {
try {
await connection.execute(`DROP INDEX \`${keyName}\` ON \`${table}\``);
- console.log(`Dropped index: ${keyName}`);
+ report.push(`Dropped index: ${keyName}`);
} catch (err) {
- console.warn(`Could not drop ${keyName}: ${err.code || err.message}`);
+ report.push(`Could not drop ${keyName}: ${err.code || err.message}`);
}
}
@@ -52,9 +55,9 @@ async function cleanupUserTokenKeys() {
// Unique on token (column is 'token')
try {
await connection.execute(`CREATE UNIQUE INDEX \`uniq_UserToken_token\` ON \`${table}\` (\`token\`)`);
- console.log('Created UNIQUE index: uniq_UserToken_token (token)');
+ report.push('Created UNIQUE index: uniq_UserToken_token (token)');
} catch (err) {
- console.warn('Could not create uniq_UserToken_token:', err.code || err.message);
+ report.push(`Could not create uniq_UserToken_token: ${err.code || err.message}`);
}
// Helpful index on user_id if column exists
@@ -62,26 +65,31 @@ async function cleanupUserTokenKeys() {
const [cols] = await connection.execute(`SHOW COLUMNS FROM \`${table}\` LIKE 'user_id'`);
if (cols && cols.length > 0) {
await connection.execute(`CREATE INDEX \`idx_UserToken_user_id\` ON \`${table}\` (\`user_id\`)`);
- console.log('Created INDEX: idx_UserToken_user_id (user_id)');
+ report.push('Created INDEX: idx_UserToken_user_id (user_id)');
} else {
- console.log('Column user_id not found, skip creating idx_UserToken_user_id');
+ report.push('Column user_id not found, skip creating idx_UserToken_user_id');
}
} catch (err) {
- console.warn('Could not create idx_UserToken_user_id:', err.code || err.message);
+ report.push(`Could not create idx_UserToken_user_id: ${err.code || err.message}`);
}
- console.log(`\nAfter cleanup (indexes on ${table}):`);
+ report.push('');
+ report.push(`After cleanup (indexes on ${table}):`);
const after = await getIndexSummary(connection, table);
Object.entries(after).forEach(([name, info]) => {
- console.log(` - ${name} ${info.unique ? '(UNIQUE)' : ''} -> [${info.columns.join(', ')}]`);
+ report.push(` - ${name} ${info.unique ? '(UNIQUE)' : ''} -> [${info.columns.join(', ')}]`);
});
- console.log('\nDone.');
+ report.push('');
+ report.push('Done.');
} catch (err) {
console.error('Cleanup failed:', err);
process.exitCode = 1;
} finally {
if (connection) await connection.end();
+ if (report.length > 0) {
+ process.stdout.write(`${report.join('\n')}\n`);
+ }
}
}
diff --git a/backend/scripts/createTestUsers.js b/backend/scripts/createTestUsers.js
index ea16bfa..adaf341 100644
--- a/backend/scripts/createTestUsers.js
+++ b/backend/scripts/createTestUsers.js
@@ -47,7 +47,8 @@ const TEST_USERS = [
];
async function createTestUsers() {
- console.log('Creating test users...\n');
+ const report = [];
+ report.push('Creating test users...');
try {
// Get first club (or specify club ID)
@@ -59,16 +60,16 @@ async function createTestUsers() {
}
const club = clubs[0];
- console.log(`Using club: ${club.name} (ID: ${club.id})\n`);
+ report.push(`Using club: ${club.name} (ID: ${club.id})`);
for (const userData of TEST_USERS) {
- console.log(`Creating user: ${userData.email} (${userData.role})...`);
+ report.push(`Creating user: ${userData.email} (${userData.role})...`);
// Check if user already exists
let user = await User.findOne({ where: { email: userData.email } });
if (user) {
- console.log(` ⚠️ User already exists, using existing user`);
+ report.push(' ⚠️ User already exists, using existing user');
} else {
// Create user
user = await User.create({
@@ -76,7 +77,7 @@ async function createTestUsers() {
password: userData.password,
isActive: true
});
- console.log(` ✓ User created`);
+ report.push(' ✓ User created');
}
// Check if user is already in club
@@ -88,13 +89,13 @@ async function createTestUsers() {
});
if (userClub) {
- console.log(` ⚠️ User already in club, updating role...`);
+ report.push(' ⚠️ User already in club, updating role...');
await userClub.update({
role: userData.role,
isOwner: userData.isOwner,
approved: true
});
- console.log(` ✓ Updated to role: ${userData.role}`);
+ report.push(` ✓ Updated to role: ${userData.role}`);
} else {
// Add user to club
userClub = await UserClub.create({
@@ -104,31 +105,37 @@ async function createTestUsers() {
isOwner: userData.isOwner,
approved: true
});
- console.log(` ✓ Added to club with role: ${userData.role}`);
+ report.push(` ✓ Added to club with role: ${userData.role}`);
}
}
- console.log('\n✅ Test users created successfully!\n');
+ report.push('');
+ report.push('✅ Test users created successfully!');
// Show summary
- console.log('Summary:');
- console.log('========================================');
- console.log(`Club: ${club.name}`);
- console.log('\nTest Users:');
+ report.push('Summary:');
+ report.push('========================================');
+ report.push(`Club: ${club.name}`);
+ report.push('');
+ report.push('Test Users:');
for (const userData of TEST_USERS) {
- console.log(` ${userData.email.padEnd(25)} | ${userData.role.padEnd(15)} | Password: test123`);
+ report.push(` ${userData.email.padEnd(25)} | ${userData.role.padEnd(15)} | Password: test123`);
}
- console.log('\n========================================');
- console.log('You can now login with any of these users!');
- console.log('All passwords are: test123');
+ report.push('');
+ report.push('========================================');
+ report.push('You can now login with any of these users!');
+ report.push('All passwords are: test123');
} catch (error) {
console.error('❌ Error creating test users:', error);
throw error;
} finally {
await sequelize.close();
+ if (report.length > 0) {
+ process.stdout.write(`${report.join('\n')}\n`);
+ }
}
}
diff --git a/backend/scripts/migratePermissions.js b/backend/scripts/migratePermissions.js
index 96d383b..e6fa766 100644
--- a/backend/scripts/migratePermissions.js
+++ b/backend/scripts/migratePermissions.js
@@ -11,7 +11,8 @@ import sequelize from '../database.js';
*/
async function migratePermissions() {
- console.log('Starting permissions migration...\n');
+ const report = [];
+ report.push('Starting permissions migration...');
try {
// Get all clubs
@@ -29,10 +30,11 @@ async function migratePermissions() {
}]
});
- console.log(`Found ${clubs.length} club(s)\n`);
+ report.push(`Found ${clubs.length} club(s)`);
for (const club of clubs) {
- console.log(`\n--- Club: ${club.name} (ID: ${club.id}) ---`);
+ report.push(``);
+ report.push(`--- Club: ${club.name} (ID: ${club.id}) ---`);
const userClubs = await UserClub.findAll({
where: {
@@ -47,15 +49,15 @@ async function migratePermissions() {
});
if (userClubs.length === 0) {
- console.log(' No approved members found.');
+ report.push(' No approved members found.');
continue;
}
// First user becomes owner
const firstUser = userClubs[0];
- console.log(` Members found: ${userClubs.length}`);
- console.log(` First member (will be owner): ${firstUser.user.email}`);
+ report.push(` Members found: ${userClubs.length}`);
+ report.push(` First member (will be owner): ${firstUser.user.email}`);
for (let i = 0; i < userClubs.length; i++) {
const userClub = userClubs[i];
@@ -71,12 +73,14 @@ async function migratePermissions() {
await userClub.save();
- console.log(` ✓ Updated ${userClub.user.email}: role=${userClub.role}, isOwner=${userClub.isOwner}`);
+ report.push(` ✓ Updated ${userClub.user.email}: role=${userClub.role}, isOwner=${userClub.isOwner}`);
}
}
- console.log('\n✅ Migration completed successfully!');
- console.log('\nSummary:');
+ report.push('');
+ report.push('✅ Migration completed successfully!');
+ report.push('');
+ report.push('Summary:');
// Show summary
const owners = await UserClub.findAll({
@@ -95,9 +99,9 @@ async function migratePermissions() {
]
});
- console.log(`\nClub Owners (${owners.length}):`);
+ report.push(`\nClub Owners (${owners.length}):`);
for (const owner of owners) {
- console.log(` - ${owner.club.name}: ${owner.user.email}`);
+ report.push(` - ${owner.club.name}: ${owner.user.email}`);
}
const admins = await UserClub.count({
@@ -107,15 +111,19 @@ async function migratePermissions() {
where: { role: 'member' }
});
- console.log(`\nRole Distribution:`);
- console.log(` - Admins: ${admins}`);
- console.log(` - Members: ${members}`);
+ report.push('');
+ report.push('Role Distribution:');
+ report.push(` - Admins: ${admins}`);
+ report.push(` - Members: ${members}`);
} catch (error) {
console.error('❌ Migration failed:', error);
throw error;
} finally {
await sequelize.close();
+ if (report.length > 0) {
+ process.stdout.write(`${report.join('\n')}\n`);
+ }
}
}
diff --git a/backend/scripts/quickFixOwner.js b/backend/scripts/quickFixOwner.js
index 90d25ff..95ed083 100644
--- a/backend/scripts/quickFixOwner.js
+++ b/backend/scripts/quickFixOwner.js
@@ -9,15 +9,15 @@ import sequelize from '../database.js';
*/
async function quickFixOwners() {
- console.log('Quick Fix: Setting club owners...\n');
+ const report = [];
+ report.push('Quick Fix: Setting club owners...');
try {
const clubs = await Club.findAll();
-
- console.log(`Found ${clubs.length} club(s)\n`);
+ report.push(`Found ${clubs.length} club(s)`);
for (const club of clubs) {
- console.log(`Club: ${club.name} (ID: ${club.id})`);
+ report.push(`Club: ${club.name} (ID: ${club.id})`);
// Find all approved members, ordered by creation date
const userClubs = await UserClub.findAll({
@@ -34,7 +34,7 @@ async function quickFixOwners() {
});
if (userClubs.length === 0) {
- console.log(' ⚠️ No approved members\n');
+ report.push(' ⚠️ No approved members');
continue;
}
@@ -58,21 +58,20 @@ async function quickFixOwners() {
role: 'admin'
});
- console.log(` ✅ Owner: ${firstUserClub.user.email}`);
+ report.push(` ✅ Owner: ${firstUserClub.user.email}`);
// Set role for other members if not set
for (let i = 1; i < userClubs.length; i++) {
const uc = userClubs[i];
if (!uc.role) {
await uc.update({ role: 'member' });
- console.log(` 👤 Member: ${uc.user.email}`);
+ report.push(` 👤 Member: ${uc.user.email}`);
}
}
-
- console.log('');
+ report.push('');
}
- console.log('✅ Quick fix completed!\n');
+ report.push('✅ Quick fix completed!');
// Show all owners
const owners = await UserClub.findAll({
@@ -82,10 +81,9 @@ async function quickFixOwners() {
{ model: Club, as: 'club', attributes: ['name'] }
]
});
-
- console.log('Current Club Owners:');
+ report.push('Current Club Owners:');
for (const owner of owners) {
- console.log(` 📍 ${owner.club.name}: ${owner.user.email} (role: ${owner.role})`);
+ report.push(` 📍 ${owner.club.name}: ${owner.user.email} (role: ${owner.role})`);
}
} catch (error) {
@@ -93,6 +91,9 @@ async function quickFixOwners() {
throw error;
} finally {
await sequelize.close();
+ if (report.length > 0) {
+ process.stdout.write(`${report.join('\n')}\n`);
+ }
}
}
diff --git a/backend/server.js b/backend/server.js
index 99b12bc..a74d931 100644
--- a/backend/server.js
+++ b/backend/server.js
@@ -235,12 +235,7 @@ app.get('*', (req, res) => {
// Start scheduler service
schedulerService.start();
- app.listen(port, () => {
- console.log(`Server is running on http://localhost:${port}`);
- console.log('Scheduler service started:');
- console.log(' - Rating updates: 6:00 AM daily');
- console.log(' - Match results fetch: 6:30 AM daily');
- });
+ app.listen(port);
} catch (err) {
console.error('Unable to synchronize the database:', err);
}
diff --git a/backend/services/diaryDateActivityService.js b/backend/services/diaryDateActivityService.js
index 6c2be9c..95b21a4 100644
--- a/backend/services/diaryDateActivityService.js
+++ b/backend/services/diaryDateActivityService.js
@@ -277,12 +277,6 @@ class DiaryDateActivityService {
throw new Error('Group not found');
}
- console.log('[DiaryDateActivityService::addGroupActivity] Group found:', {
- groupId: group.id,
- groupDiaryDateId: group.diaryDateId,
- activityDiaryDateId: diaryDateActivity.diaryDateId
- });
-
if (group.diaryDateId !== diaryDateActivity.diaryDateId) {
console.error('[DiaryDateActivityService::addGroupActivity] Group and date don\'t fit');
console.error('Group diaryDateId:', group.diaryDateId, 'Activity diaryDateId:', diaryDateActivity.diaryDateId);
diff --git a/backend/services/memberService.js b/backend/services/memberService.js
index 0107165..97ecf94 100644
--- a/backend/services/memberService.js
+++ b/backend/services/memberService.js
@@ -230,7 +230,6 @@ class MemberService {
try {
session = await myTischtennisService.getSession(userId);
} catch (sessionError) {
- console.log('[updateRatingsFromMyTischtennis] - Session invalid, attempting login...', sessionError.message);
// Versuche automatischen Login mit gespeicherten Credentials
try {
@@ -243,7 +242,6 @@ class MemberService {
expiresAt: freshSession.expiresAt,
userData: freshSession.userData
};
- console.log('[updateRatingsFromMyTischtennis] - Automatic login successful');
} catch (loginError) {
console.error('[updateRatingsFromMyTischtennis] - Automatic login failed:', loginError.message);
return {
@@ -354,6 +352,7 @@ class MemberService {
account.fedNickname,
'no'
);
+ let qttrWarning = null;
try {
await (await import('./apiLogService.js')).default.logRequest({
userId,
@@ -386,7 +385,7 @@ class MemberService {
}
if (!rankingsQuarter.success) {
// QTTR optional; nicht hart abbrechen, aber vermerken
- console.warn('[updateRatingsFromMyTischtennis] - QTTR Abruf fehlgeschlagen:', rankingsQuarter.error);
+ qttrWarning = rankingsQuarter.error || 'QTTR Abruf fehlgeschlagen';
}
// 3. Alle Mitglieder des Clubs laden
@@ -394,6 +393,12 @@ class MemberService {
let updated = 0;
const errors = [];
+ if (qttrWarning) {
+ errors.push({
+ type: 'warning',
+ message: qttrWarning
+ });
+ }
const notFound = [];
const matched = [];
diff --git a/backend/services/pdfParserService.js b/backend/services/pdfParserService.js
index 2b55b11..883dec6 100644
--- a/backend/services/pdfParserService.js
+++ b/backend/services/pdfParserService.js
@@ -109,21 +109,11 @@ class PDFParserService {
const result = strategy.fn(lines, clubId, filteredLineEntries.length === lines.length ? filteredLineEntries : null);
if (result.matches.length > 0) {
- console.log(`[PDF Parser] Using strategy: ${strategy.name}, found ${result.matches.length} matches`);
- if (result.matches.length > 0) {
- console.log(`[PDF Parser] First match sample:`, {
- homeTeamName: result.matches[0].homeTeamName,
- guestTeamName: result.matches[0].guestTeamName,
- date: result.matches[0].date,
- rawLine: result.matches[0].rawLine
- });
- }
matches.push(...result.matches);
metadata.parsedMatches += result.matches.length;
break; // Erste erfolgreiche Strategie verwenden
}
} catch (strategyError) {
- console.log(`[PDF Parser] Strategy ${strategy.name} failed:`, strategyError.message);
errors.push(`Strategy ${strategy.name} failed: ${strategyError.message}`);
}
}
@@ -423,18 +413,6 @@ class PDFParserService {
}
if (homeTeamName && guestTeamName) {
- let debugInfo;
- if (code) {
- debugInfo = `code: "${code}"`;
- } else if (homePin && guestPin) {
- debugInfo = `homePin: "${homePin}", guestPin: "${guestPin}"`;
- } else if (homePin) {
- debugInfo = `homePin: "${homePin}"`;
- } else if (guestPin) {
- debugInfo = `guestPin: "${guestPin}"`;
- }
-
- console.log(`[PDF Parser] Parsed match: ${homeTeamName} vs ${guestTeamName}, ${debugInfo}`);
matches.push({
date: date,
@@ -769,27 +747,18 @@ class PDFParserService {
where: { clubId: matchData.clubId },
attributes: ['id', 'name']
});
- console.log(`[PDF Parser] Available teams in club: ${allTeams.map(t => t.name).join(', ')}`);
// Fuzzy-Matching für Team-Namen
if (!homeTeam) {
homeTeam = allTeams.find(t =>
PDFParserService.namesRoughlyMatch(t.name, matchData.homeTeamName)
);
-
- if (homeTeam) {
- console.log(`[PDF Parser] Found home team via fuzzy match: "${matchData.homeTeamName}" → "${homeTeam.name}"`);
- }
}
if (!guestTeam) {
guestTeam = allTeams.find(t =>
PDFParserService.namesRoughlyMatch(t.name, matchData.guestTeamName)
);
-
- if (guestTeam) {
- console.log(`[PDF Parser] Found guest team via fuzzy match: "${matchData.guestTeamName}" → "${guestTeam.name}"`);
- }
}
}
diff --git a/backend/services/schedulerService.js b/backend/services/schedulerService.js
index 439b254..0532d67 100644
--- a/backend/services/schedulerService.js
+++ b/backend/services/schedulerService.js
@@ -24,28 +24,22 @@ class SchedulerService {
// Schedule automatic rating updates at 6:00 AM daily
const ratingUpdateJob = cron.schedule('0 6 * * *', async () => {
const startTime = Date.now();
- const timestamp = new Date().toISOString();
- console.log(`[${timestamp}] CRON: Executing scheduled rating updates...`);
- devLog('Executing scheduled rating updates...');
+ devLog(`[${new Date().toISOString()}] CRON: Executing scheduled rating updates...`);
- let success = false;
- let message = '';
let errorMessage = null;
try {
// Let the service return details including counts if available
const result = await autoUpdateRatingsService.executeAutomaticUpdates();
const executionTime = Date.now() - startTime;
- success = true;
// result may include updatedCount or a summary object
const messageObj = result && typeof result === 'object' ? result : { message: 'Rating updates completed successfully' };
- console.log(`[${new Date().toISOString()}] CRON: Rating updates completed successfully`);
// Log to ApiLog with rich details
await apiLogService.logSchedulerExecution('rating_updates', true, messageObj, executionTime, null);
+ devLog('Scheduled rating updates completed successfully');
} catch (error) {
const executionTime = Date.now() - startTime;
- success = false;
errorMessage = error.message;
console.error(`[${new Date().toISOString()}] CRON ERROR in scheduled rating updates:`, error);
console.error('Stack trace:', error.stack);
@@ -60,32 +54,26 @@ class SchedulerService {
this.jobs.set('ratingUpdates', ratingUpdateJob);
ratingUpdateJob.start();
- console.log('[Scheduler] Rating update job scheduled and started');
+ devLog('Rating update job scheduled and started');
// Schedule automatic match results fetching at 6:30 AM daily
const matchResultsJob = cron.schedule('30 6 * * *', async () => {
const startTime = Date.now();
- const timestamp = new Date().toISOString();
- console.log(`[${timestamp}] CRON: Executing scheduled match results fetch...`);
- devLog('Executing scheduled match results fetch...');
+ devLog(`[${new Date().toISOString()}] CRON: Executing scheduled match results fetch...`);
- let success = false;
- let message = '';
let errorMessage = null;
try {
// Execute and capture returned summary (should include counts)
const result = await autoFetchMatchResultsService.executeAutomaticFetch();
const executionTime = Date.now() - startTime;
- success = true;
const messageObj = result && typeof result === 'object' ? result : { message: 'Match results fetch completed successfully' };
- console.log(`[${new Date().toISOString()}] CRON: Match results fetch completed successfully`);
// Log to ApiLog with rich details (including counts if present)
await apiLogService.logSchedulerExecution('match_results', true, messageObj, executionTime, null);
+ devLog('Scheduled match results fetch completed successfully');
} catch (error) {
const executionTime = Date.now() - startTime;
- success = false;
errorMessage = error.message;
console.error(`[${new Date().toISOString()}] CRON ERROR in scheduled match results fetch:`, error);
console.error('Stack trace:', error.stack);
@@ -100,7 +88,7 @@ class SchedulerService {
this.jobs.set('matchResults', matchResultsJob);
matchResultsJob.start();
- console.log('[Scheduler] Match results fetch job scheduled and started');
+ devLog('Match results fetch job scheduled and started');
this.isRunning = true;
const now = new Date();
@@ -112,12 +100,12 @@ class SchedulerService {
tomorrow630AM.setDate(tomorrow630AM.getDate() + 1);
tomorrow630AM.setHours(6, 30, 0, 0);
- console.log('[Scheduler] ===== SCHEDULER SERVICE STARTED =====');
- console.log(`[Scheduler] Server time: ${now.toISOString()}`);
- console.log(`[Scheduler] Timezone: Europe/Berlin`);
- console.log(`[Scheduler] Rating updates: Next execution at ${tomorrow6AM.toISOString()} (6:00 AM Berlin time)`);
- console.log(`[Scheduler] Match results fetch: Next execution at ${tomorrow630AM.toISOString()} (6:30 AM Berlin time)`);
- console.log('[Scheduler] =====================================');
+ devLog('[Scheduler] ===== SCHEDULER SERVICE STARTED =====');
+ devLog(`[Scheduler] Server time: ${now.toISOString()}`);
+ devLog(`[Scheduler] Timezone: Europe/Berlin`);
+ devLog(`[Scheduler] Rating updates: Next execution at ${tomorrow6AM.toISOString()} (6:00 AM Berlin time)`);
+ devLog(`[Scheduler] Match results fetch: Next execution at ${tomorrow630AM.toISOString()} (6:30 AM Berlin time)`);
+ devLog('[Scheduler] =====================================');
devLog('Scheduler service started successfully');
devLog('Rating updates scheduled for 6:00 AM daily (Europe/Berlin timezone)');
diff --git a/backend/services/tournamentService.js b/backend/services/tournamentService.js
index 5a3c415..6f95629 100644
--- a/backend/services/tournamentService.js
+++ b/backend/services/tournamentService.js
@@ -207,7 +207,6 @@ class TournamentService {
const gm = await TournamentMember.findAll({ where: { groupId: g.id } });
if (gm.length < 2) {
- console.warn(`Gruppe ${g.id} hat nur ${gm.length} Teilnehmer - keine Matches erstellt`);
continue;
}
@@ -227,8 +226,6 @@ class TournamentService {
player2Id: p2Id,
groupRound: roundIndex + 1
});
- } else {
- console.warn(`Spieler gehören nicht zur gleichen Gruppe: ${p1Id} (${p1?.groupId}) vs ${p2Id} (${p2?.groupId}) in Gruppe ${g.id}`);
}
}
}
diff --git a/backend/utils/encrypt.js b/backend/utils/encrypt.js
index 5aab2e3..03477b4 100644
--- a/backend/utils/encrypt.js
+++ b/backend/utils/encrypt.js
@@ -18,7 +18,6 @@ function encryptData(data) {
encrypted += cipher.final('hex');
return encrypted;
} catch (error) {
- console.log(error, data, process.env.ENCRYPTION_KEY, typeof data, process.env.ENCRYPTION_KEY.length);
return '';
}
}
diff --git a/frontend/src/components/DIALOG_TEMPLATES.md b/frontend/src/components/DIALOG_TEMPLATES.md
index b600ea8..bd51358 100644
--- a/frontend/src/components/DIALOG_TEMPLATES.md
+++ b/frontend/src/components/DIALOG_TEMPLATES.md
@@ -71,7 +71,7 @@ export default {
const isOpen = ref(false);
const handleClose = () => {
- console.log('Dialog geschlossen');
+ // Reagiere auf das Schließen des Dialogs
};
return { isOpen, handleClose };
@@ -163,11 +163,11 @@ export default {
const showConfirm = ref(false);
const handleDelete = () => {
- console.log('Gelöscht');
+ // Lösche den Eintrag
};
const handleCancel = () => {
- console.log('Abgebrochen');
+ // Brich die Aktion ab
};
return { showConfirm, handleDelete, handleCancel };
@@ -307,108 +307,4 @@ toggle();
Promise-basiertes Composable für Bestätigungsdialoge.
-```javascript
-import { useConfirm } from '@/composables/useDialog.js';
-
-const { isOpen, config, confirm, handleConfirm, handleCancel } = useConfirm();
-
-// Im Template:
-