Refactor code structure for improved readability and maintainability
All checks were successful
Deploy tt-tagebuch / deploy (push) Successful in 53s

This commit is contained in:
Torsten Schulz (local)
2026-05-27 23:53:41 +02:00
parent 2e7cf0c28d
commit e57cdc6ad8
25 changed files with 156689 additions and 171 deletions

View File

@@ -0,0 +1,38 @@
import PredefinedActivity from '../models/PredefinedActivity.js';
import sequelize from '../database.js';
async function check() {
try {
await sequelize.authenticate();
const rows = await PredefinedActivity.findAll({ attributes: ['id', 'name', 'drawingData'] });
const invalid = [];
for (const r of rows) {
const id = r.id;
const name = r.name;
const raw = r.drawingData;
if (raw == null) continue;
if (typeof raw !== 'string') {
invalid.push({ id, name, reason: 'not-string', raw: String(raw).slice(0, 200) });
continue;
}
try {
JSON.parse(raw);
} catch (e) {
// If raw looks like an object literal without quotes, consider invalid
invalid.push({ id, name, reason: 'invalid-json', error: e.message, raw: raw.slice(0, 200) });
}
}
if (invalid.length === 0) {
console.log('No invalid drawingData found.');
} else {
console.log('Invalid drawingData rows:');
invalid.forEach(i => console.log(JSON.stringify(i)));
}
} catch (err) {
console.error('Script error', err);
} finally {
await sequelize.close();
}
}
check();