From bef2c613a9e83dd6351e388b157910f787e30d2a Mon Sep 17 00:00:00 2001 From: zkldi Date: Mon, 31 May 2021 19:21:03 +0100 Subject: [PATCH] Document returns of ReprocessOrphan --- .../lib/score-import/framework/orphans/orphans.ts | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/server/src/lib/score-import/framework/orphans/orphans.ts b/server/src/lib/score-import/framework/orphans/orphans.ts index d75e67893..eef21706a 100644 --- a/server/src/lib/score-import/framework/orphans/orphans.ts +++ b/server/src/lib/score-import/framework/orphans/orphans.ts @@ -63,11 +63,13 @@ export async function OrphanScore( } /** - * Attempts to de-orphan scores by re-running a import with their data. - * @param userID - The userID to attempt to de-orphan scores from. + * Takes an orphan document and re-runs the converter->scoreimport pipeline on its data. + * + * @returns False if no parent documents could be found for the score again, + * Null if the orphan document was removed, but no score was inserted (i.e. score was orphaned AND invalid, so nothing + * could be imported when parents were found). + * ImportProcessingInfo on success. */ -export async function ReprocessOrphans(userID: integer) {} - export async function ReprocessOrphan(orphan: OrphanScoreDocument, logger: KtLogger) { const ConverterFunction = Converters[orphan.importType] as ConverterFunction< ImportTypeDataMap[ImportTypes], @@ -111,9 +113,11 @@ export async function ReprocessOrphan(orphan: OrphanScoreDocument, logger: KtLog // remove a users score. await db["orphan-scores"].remove({ orphanID: orphan.orphanID }); - return false; + return null; } + await db["orphan-scores"].remove({ orphanID: orphan.orphanID }); + // else, import the orphan. return ProcessSuccessfulConverterReturn(orphan.userID, res, logger); }