🔧 Cleaned up unused code and bumped filename-parser

This commit is contained in:
2022-02-07 09:56:08 -08:00
parent bfb1f7fa28
commit 8bb74404fc
8 changed files with 24 additions and 76 deletions

View File

@@ -63,7 +63,7 @@ const ComicSchema = mongoose.Schema({
inferredMetadata: {
issue: {
name: String,
number: { type: Number, es_indexed: true },
number: { type: Number, es_indexed: true, required: false, default: 0 },
year: String,
subtitle: String,
}
@@ -83,6 +83,7 @@ const ComicSchema = mongoose.Schema({
},
},
}, { timestamps: true});
ComicSchema.plugin(mexp, {
client: eSClient,
});

14
package-lock.json generated
View File

@@ -23,7 +23,7 @@
"chokidar": "^3.5.3",
"delay": "^5.0.0",
"dotenv": "^10.0.0",
"filename-parser": "^1.0.1",
"filename-parser": "^1.0.4",
"fs-extra": "^10.0.0",
"imghash": "^0.0.9",
"ioredis": "^4.28.1",
@@ -4701,9 +4701,9 @@
}
},
"node_modules/filename-parser": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/filename-parser/-/filename-parser-1.0.1.tgz",
"integrity": "sha512-MMzuklXc1r4N6uQXg8CQYxoiTX7w6QPeJE73L5lCTSoNR7CftCXHIA6tyINomkvWIUanrlqTB629DyTIqCucEA==",
"version": "1.0.4",
"resolved": "https://registry.npmjs.org/filename-parser/-/filename-parser-1.0.4.tgz",
"integrity": "sha512-r/cFGGlCFaz2taSlDzOtVWO66WvqPDBv6CtyqKw4GCP7+V3r5D5J0ci3fnYaDm5/GkqWL5aGA6JTbu8e+oKQMA==",
"dependencies": {
"compromise": "^13.11.4",
"compromise-dates": "^2.2.1",
@@ -15795,9 +15795,9 @@
"integrity": "sha512-uzk64HRpUZyTGZtVuvrjP0FYxzQrBf4rojot6J65YMEbwBLB0CWm0CLojVpwpmFmxcE/lkvYICgfcGozbBq6rw=="
},
"filename-parser": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/filename-parser/-/filename-parser-1.0.1.tgz",
"integrity": "sha512-MMzuklXc1r4N6uQXg8CQYxoiTX7w6QPeJE73L5lCTSoNR7CftCXHIA6tyINomkvWIUanrlqTB629DyTIqCucEA==",
"version": "1.0.4",
"resolved": "https://registry.npmjs.org/filename-parser/-/filename-parser-1.0.4.tgz",
"integrity": "sha512-r/cFGGlCFaz2taSlDzOtVWO66WvqPDBv6CtyqKw4GCP7+V3r5D5J0ci3fnYaDm5/GkqWL5aGA6JTbu8e+oKQMA==",
"requires": {
"compromise": "^13.11.4",
"compromise-dates": "^2.2.1",

View File

@@ -50,7 +50,7 @@
"chokidar": "^3.5.3",
"delay": "^5.0.0",
"dotenv": "^10.0.0",
"filename-parser": "^1.0.1",
"filename-parser": "^1.0.4",
"fs-extra": "^10.0.0",
"imghash": "^0.0.9",
"ioredis": "^4.28.1",

View File

@@ -145,7 +145,7 @@ export default class ApiService extends Service {
await broker.call("library.walkFolders", {
basePathToWalk: path,
});
await this.broker.call("library.processImport", {
await this.broker.call("queue.processImport", {
fileObject: {
filePath: walkedFolder[0].filePath,
fileSize: walkedFolder[0].fileSize,

View File

@@ -152,11 +152,14 @@ export default class ImportService extends Service {
async handler(
ctx: Context<{
sourcedMetadata: {
comicvine: {
comicvine?: {
volume: { api_detail_url: string };
volumeInformation: {};
};
};
inferredMetadata: {
issue: Object,
},
rawFileDetails: {
name: string;
};
@@ -164,6 +167,8 @@ export default class ImportService extends Service {
) {
let volumeDetails;
const comicMetadata = ctx.params;
// When an issue is added from the search CV feature
if (
comicMetadata.sourcedMetadata.comicvine &&
!isNil(
@@ -186,11 +191,13 @@ export default class ImportService extends Service {
if (data) {
resolve(data);
} else if (error) {
console.log("data", data);
console.log("error", error)
throw new Errors.MoleculerError(
"Failed to import comic book",
400,
"IMS_FAILED_COMIC_BOOK_IMPORT",
data
error
);
}
});
@@ -411,12 +418,6 @@ export default class ImportService extends Service {
elasticSearchQuery = {
bool: {
must: [
// {
// match_phrase: {
// "rawFileDetails.name":
// queryObject.issueName,
// },
// },
{
match_phrase: {
"rawFileDetails.name":

View File

@@ -152,35 +152,6 @@ export default class QueueService extends Service {
);
}
);
await this.getQueue("issue.findMatchesInLibrary").on(
"failed",
async (job, error) => {
console.error(
`An error occured in 'issue.findMatchesInLibrary' queue on job id '${job.id}': ${error.message}`
);
}
);
await this.getQueue("issue.findMatchesInLibrary").on(
"completed",
async (job, res) => {
client.emit("action", {
type: "CV_ISSUES_FOR_VOLUME_IN_LIBRARY_UPDATED",
result: res,
});
console.info(
`Job with the id '${job.id}' completed.`
);
}
);
await this.getQueue("issue.findMatchesInLibrary").on(
"stalled",
async (job) => {
console.warn(
`The job with the id '${job} got stalled!`
);
}
);
});
},
});

View File

@@ -59,31 +59,6 @@ export default class SettingsService extends Service {
})
return body.responses;
// return Comic.esSearch({
// query: elasticSearchQuery,
// }).then(function (results) {
// // results here
// const foo = results.body.hits.hits.map(
// (hit) => {
// const parsedFilename = refineQuery(
// hit._source.rawFileDetails.name
// );
// if (
// parsedFilename.searchParams
// .searchTerms.number ===
// parseInt(
// ctx.params.queryObject
// .issueNumber,
// 10
// )
// ) {
// return hit;
// }
// }
// );
// return filter(foo, null);
// });
},
},
},

View File

@@ -2634,10 +2634,10 @@
"resolved" "https://registry.npmjs.org/file-type/-/file-type-10.11.0.tgz"
"version" "10.11.0"
"filename-parser@^1.0.1":
"integrity" "sha512-MMzuklXc1r4N6uQXg8CQYxoiTX7w6QPeJE73L5lCTSoNR7CftCXHIA6tyINomkvWIUanrlqTB629DyTIqCucEA=="
"resolved" "https://registry.npmjs.org/filename-parser/-/filename-parser-1.0.1.tgz"
"version" "1.0.1"
"filename-parser@^1.0.4":
"integrity" "sha512-r/cFGGlCFaz2taSlDzOtVWO66WvqPDBv6CtyqKw4GCP7+V3r5D5J0ci3fnYaDm5/GkqWL5aGA6JTbu8e+oKQMA=="
"resolved" "https://registry.npmjs.org/filename-parser/-/filename-parser-1.0.4.tgz"
"version" "1.0.4"
dependencies:
"compromise" "^13.11.4"
"compromise-dates" "^2.2.1"