breaking: remove multi-folder stats, and log warnings if they are used

This commit is contained in:
zkldi
2022-06-01 15:01:54 +01:00
parent 883216bff8
commit 6bed17f2e3
+16 -3
View File
@@ -25,11 +25,24 @@ export async function GetRelatedStatDocuments(stat: ShowcaseStatDetails, game: G
}
case "folder": {
const folders = await db.folders.find({
folderID: { $in: Array.isArray(stat.folderID) ? stat.folderID : [stat.folderID] },
if (Array.isArray(stat.folderID)) {
logger.warn(
`This stat is corrupt and attempted to use multiple folderIDs. This is no longer supported. Check that migrations have ran.`,
{ stat }
);
throw new Error(`Legacy FolderIDs used in showcase stat.`);
}
const folder = await db.folders.findOne({
folderID: stat.folderID,
});
return { folders };
if (!folder) {
logger.error(`This stat refers to a folder that does not exist?`, { stat });
throw new Error(`Stat refers to folder that no longer exists.`);
}
return { folder };
}
default: {