Füge Validierung für Geschenke in FalukantService hinzu und erstelle Skripte zur Reparatur ungültiger Werte in PromotionalGift
This commit is contained in:
37
backend/tools/dumpGiftsDebug.js
Normal file
37
backend/tools/dumpGiftsDebug.js
Normal file
@@ -0,0 +1,37 @@
|
||||
import { sequelize } from '../utils/sequelize.js';
|
||||
import PromotionalGift from '../models/falukant/type/promotional_gift.js';
|
||||
import PromotionalGiftMood from '../models/falukant/predefine/promotional_gift_mood.js';
|
||||
import PromotionalGiftCharacterTrait from '../models/falukant/predefine/promotional_gift_character_trait.js';
|
||||
|
||||
async function dump() {
|
||||
try {
|
||||
await sequelize.authenticate();
|
||||
console.log('DB connected');
|
||||
|
||||
const gifts = await PromotionalGift.findAll({
|
||||
include: [
|
||||
{ model: PromotionalGiftMood, as: 'promotionalgiftmoods', attributes: ['moodId', 'suitability'], required: false },
|
||||
{ model: PromotionalGiftCharacterTrait, as: 'characterTraits', attributes: ['traitId', 'suitability'], required: false }
|
||||
]
|
||||
});
|
||||
|
||||
console.log(`found ${gifts.length} gifts`);
|
||||
for (const g of gifts) {
|
||||
console.log('---');
|
||||
console.log('id:', g.id, 'name:', g.name, 'raw value type:', typeof g.value, 'value:', g.value);
|
||||
try {
|
||||
const plain = g.get({ plain: true });
|
||||
console.log('plain value:', JSON.stringify(plain));
|
||||
} catch (e) {
|
||||
console.log('could not stringify plain', e);
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
console.error('dump failed', err);
|
||||
process.exit(2);
|
||||
} finally {
|
||||
await sequelize.close();
|
||||
}
|
||||
}
|
||||
|
||||
dump();
|
||||
Reference in New Issue
Block a user