Add a warning to the logs if an ID is used twice #248

Merged
Vylpes merged 1 commit from feature/233-log-id-duplicate into develop 2024-06-01 14:52:39 +01:00

View file

@ -39,6 +39,13 @@ export default class CardMetadataFunction {
CoreClient.Cards = cardResult.Result!; CoreClient.Cards = cardResult.Result!;
AppLogger.LogInfo("Functions/CardMetadataFunction", `Loaded ${CoreClient.Cards.flatMap(x => x.cards).length} cards to database`); AppLogger.LogInfo("Functions/CardMetadataFunction", `Loaded ${CoreClient.Cards.flatMap(x => x.cards).length} cards to database`);
const duplicateCards = CoreClient.Cards.flatMap(x => x.cards)
.filter((card, index, self) => self.findIndex(c => c.id === card.id) !== index);
if (duplicateCards.length > 0) {
AppLogger.LogWarn("Functions/CardMetadataFunction", `Duplicate card ids found: ${duplicateCards.flatMap(x => x.id).join(", ")}`);
}
return { return {
IsSuccess: true, IsSuccess: true,
}; };