Skip to content

Commit

Permalink
removed await log where unneccesary
Browse files Browse the repository at this point in the history
  • Loading branch information
nleanba committed May 17, 2024
1 parent ea65c03 commit fe91990
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions src/worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const _worker = new GHActWorker(
self,
ghActConfig,
async (job: Job, log): Promise<void> => {
await log(
log(
"Starting transformation\n" + JSON.stringify(job, undefined, 2),
);

Expand Down Expand Up @@ -51,23 +51,23 @@ const _worker = new GHActWorker(
);
}

await log(`> got added ${added}`); // -> LOAD
await log(`> got removed ${removed}`); // -> DROP graphname
await log(`> got modified ${modified}`); // DROP; LOAD
log(`> got added ${added}`); // -> LOAD
log(`> got removed ${removed}`); // -> DROP graphname
log(`> got modified ${modified}`); // DROP; LOAD

const statements = [
...added.map((f) => ({ statement: LOAD(f), fileName: f })),
...removed.map((f) => ({ statement: DROP(f), fileName: f })),
...modified.map((f) => ({ statement: UPDATE(f), fileName: f })),
];

await log(`- statement count: ${statements.length}`);
log(`- statement count: ${statements.length}`);

const failingFiles: string[] = [];
let succeededOnce = false;

for (const { statement, fileName } of statements) {
await log(`» handling ${fileName}\n ${statement}`);
log(`» handling ${fileName}\n ${statement}`);
try {
const response = await fetch(sparqlConfig.uploadUri, {
method: "POST",
Expand All @@ -76,27 +76,27 @@ const _worker = new GHActWorker(
});
if (response.ok) {
succeededOnce = true;
await log("» success");
log("» success");
} else {
throw new Error(
`Got ${response.status}:\n` + await response.text(),
);
}
} catch (error) {
failingFiles.push(fileName);
await log(" » error:");
await log("" + error);
log(" » error:");
log("" + error);
}
}

await log("< done");
log("< done");
if (!succeededOnce) {
await log(`All failed:\n ${failingFiles.join("\n ")}`);
log(`All failed:\n ${failingFiles.join("\n ")}`);
throw new Error(`All failed`);
} else if (failingFiles.length > 0) {
await log(`Some failed:\n ${failingFiles.join("\n ")}`);
log(`Some failed:\n ${failingFiles.join("\n ")}`);
} else {
await log("All succeeded");
log("All succeeded");
}
},
);

0 comments on commit fe91990

Please sign in to comment.