🔨 Fixes to searchmatchscorer
Some checks failed
Docker Image CI / build (push) Has been cancelled

This commit is contained in:
2026-04-14 07:11:18 -04:00
parent 2e31f6cf49
commit c604bd8e4d

View File

@@ -152,7 +152,7 @@ export const rankVolumes = (volumes: any, scorerConfiguration: any) => {
};
const calculateLevenshteinDistance = async (match: any, rawFileDetails: any) =>
new Promise((resolve, reject) => {
new Promise((resolve) => {
https.get(match.image.small_url, (response: any) => {
console.log(rawFileDetails.cover.filePath);
const fileName = match.id + "_" + rawFileDetails.name + ".jpg";
@@ -166,6 +166,7 @@ const calculateLevenshteinDistance = async (match: any, rawFileDetails: any) =>
);
const fileStream = response.pipe(file);
fileStream.on("finish", async () => {
try {
// 1. hash of the cover image we have on hand
const coverFileName = rawFileDetails.cover.filePath
.split("/")
@@ -196,9 +197,11 @@ const calculateLevenshteinDistance = async (match: any, rawFileDetails: any) =>
} else {
match.score -= 2;
}
}
resolve(match);
} catch (err) {
console.warn(`Image hashing failed for ${fileName}, skipping score adjustment:`, err.message);
resolve(match);
} else {
reject({ error: "Couldn't calculate hashes." });
}
});
});