Move timeAchieved into the parser context so that it's saved by orphans properly instead of inferred by the converter.

This commit is contained in:
zkldi
2021-12-07 14:24:25 +00:00
parent c722adbde4
commit 25e8777514
8 changed files with 13 additions and 6 deletions
@@ -182,7 +182,7 @@ export const ConverterIRBeatoraja: ConverterFunction<BeatorajaScore, BeatorajaCo
inputDevice: data.deviceType,
random,
},
timeAchieved: Date.now(),
timeAchieved: context.timeReceived,
service: "Beatoraja IR",
};
@@ -110,12 +110,13 @@ export function ParseBeatorajaSingle(
throw new ScoreImportFatalError(400, `Unsupported client ${client}`);
}
// asserted using prudence.
return {
context: {
client: "lr2oraja",
// asserted using prudence.
chart: body.chart as BeatorajaChart,
userID,
timeReceived: Date.now(),
},
game: "bms",
iterable: [body.score] as unknown as BeatorajaScore[],
@@ -4,6 +4,7 @@ export interface BeatorajaContext {
client: "lr2oraja";
chart: BeatorajaChart;
userID: integer; // unexpectedly necessary for orphan code!
timeReceived: number;
}
export interface BeatorajaChart {
@@ -108,7 +108,7 @@ export const ConverterIRUSC: ConverterFunction<USCClientScore, IRUSCContext> = a
comment: null,
game: "usc",
importType,
timeAchieved: Date.now(),
timeAchieved: context.timeReceived,
service: "USC-IR",
scoreData: {
grade,
@@ -62,6 +62,7 @@ export function ParseIRUSC(
context: {
chartHash,
playtype,
timeReceived: Date.now(),
},
game: "usc",
iterable: [score] as USCClientScore[],
@@ -3,4 +3,5 @@ import { Playtypes } from "tachi-common";
export interface IRUSCContext {
chartHash: string;
playtype: Playtypes["usc"];
timeReceived: number;
}
@@ -334,9 +334,12 @@ router.post("/scores", RequirePermissions("submit_score"), async (req, res) => {
"context.playtype": playtype,
});
await Promise.all(
scoresToDeorphan.map((score) => ReprocessOrphan(score, blacklist, logger))
);
for (const score of scoresToDeorphan) {
// Has to be like this to avoid race conditions where two
// orphans resolve to the same scoreID and collide in mid-air!
// eslint-disable-next-line no-await-in-loop
await ReprocessOrphan(score, blacklist, logger);
}
}
}
Binary file not shown.