diff --git a/moleculer.config.ts b/moleculer.config.ts index 459c07c..b6f5393 100644 --- a/moleculer.config.ts +++ b/moleculer.config.ts @@ -57,25 +57,25 @@ const brokerConfig: BrokerOptions = { autoPadding: false, }, }, - { - type: "File", - options: { - level: "debug", - folder: "./logs", - filename: "threetwo-import-service.log", - // Using colors on the output - colors: true, - // Print module names with different colors (like docker-compose for containers) - moduleColors: false, - // Line formatter. It can be "json", "short", "simple", "full", a `Function` or a template string like "{timestamp} {level} {nodeID}/{mod}: {msg}" - formatter: "full", - // Custom object printer. If not defined, it uses the `util.inspect` method. - objectPrinter: null, - eol: "\n", - // Auto-padding the module name in order to messages begin at the same column. - autoPadding: true, - }, - }, + // { + // type: "File", + // options: { + // level: "debug", + // folder: "./logs", + // filename: "threetwo-import-service.log", + // // Using colors on the output + // colors: true, + // // Print module names with different colors (like docker-compose for containers) + // moduleColors: false, + // // Line formatter. It can be "json", "short", "simple", "full", a `Function` or a template string like "{timestamp} {level} {nodeID}/{mod}: {msg}" + // formatter: "full", + // // Custom object printer. If not defined, it uses the `util.inspect` method. + // objectPrinter: null, + // eol: "\n", + // // Auto-padding the module name in order to messages begin at the same column. + // autoPadding: true, + // }, + // }, ], // Default log level for built-in console logger. It can be overwritten in logger options above. // Available values: trace, debug, info, warn, error, fatal diff --git a/services/library.service.ts b/services/library.service.ts index a7b6325..f4ec3e7 100644 --- a/services/library.service.ts +++ b/services/library.service.ts @@ -167,7 +167,7 @@ export default class ImportService extends Service { params: {}, async handler( ctx: Context<{ - _id: string, + _id: string; sourcedMetadata: { comicvine?: { volume: { api_detail_url: string }; @@ -229,7 +229,7 @@ export default class ImportService extends Service { 500 ); } - }, + } ); } catch (error) { throw new Errors.MoleculerError( @@ -341,12 +341,12 @@ export default class ImportService extends Service { handler: async ( ctx: Context<{ comicObjectId: string; - comicObject: { + comicObject: { acquisition: { - source:{ + source: { wanted: boolean; - } - } + }; + }; }; downloadStatus: { name: string }; }> @@ -354,8 +354,11 @@ export default class ImportService extends Service { const result = await extractFromArchive( `${COMICS_DIRECTORY}/${ctx.params.downloadStatus.name}` ); - Object.assign(ctx.params.comicObject, { rawFileDetails: result }); - ctx.params.comicObject.acquisition.source.wanted = false; + Object.assign(ctx.params.comicObject, { + rawFileDetails: result, + }); + ctx.params.comicObject.acquisition.source.wanted = + false; const updateResult = await Comic.findOneAndUpdate( { _id: new ObjectId(ctx.params.comicObjectId) }, ctx.params.comicObject, @@ -510,17 +513,7 @@ export default class ImportService extends Service { }); }, }, - groupIssuesByBundles: { - rest: "GET /groupIssuesByBundles", - params: {}, - handler: async (ctx: Context<{}>) => { - // params: array of bundle IDs - // query mongo for - if(!isNil(ctx.params)) { - console.log(Object.values(ctx.params)); - } - } - }, + libraryStatistics: { rest: "GET /libraryStatistics", params: {}, diff --git a/services/search.service.ts b/services/search.service.ts index 5c60007..2d137a2 100644 --- a/services/search.service.ts +++ b/services/search.service.ts @@ -9,7 +9,7 @@ import { import { DbMixin } from "../mixins/db.mixin"; import Comic from "../models/comic.model"; -import { flatten, isEmpty, isUndefined, map } from "lodash"; +import { flatten, isEmpty, isNil, isUndefined, map } from "lodash"; import { eSClient } from "../models/comic.model"; const s = eSClient.helpers.msearch(); @@ -113,12 +113,14 @@ export default class SettingsService extends Service { case "volumes": Object.assign(eSQuery, { exists: { - field: "sourcedMetadata.comicvine.volumeInformation" - } + field: "sourcedMetadata.comicvine.volumeInformation", + }, }); break; } - console.log("Searching ElasticSearch index with this query -> "); + console.log( + "Searching ElasticSearch index with this query -> " + ); console.log( JSON.stringify(eSQuery, null, 2) ); @@ -144,6 +146,47 @@ export default class SettingsService extends Service { } }, }, + groupIssuesByBundles: { + rest: "GET /groupIssuesByBundles", + params: {}, + handler: async ( + ctx: Context<{ bundleIds: [] }> + ) => { + // params: array of bundle IDs + // construct the elasticsearch msearch query + let elasticsearchQuery = {}; + if (!isNil(ctx.params.bundleIds)) { + ctx.params.bundleIds.map(async (id) => { + let foo = await eSClient.search({ + index: "comics", + body: { + query: { + nested: { + path: "acquisition", + query: { + bool: { + must: [ + { + match: { + "acquisition.directconnect": + id, + }, + }, + ], + }, + }, + inner_hits: {}, + // ignore_unmapped: true, + }, + }, + }, + }); + console.log(foo.body); + return foo.body; + }); + } + }, + }, deleteElasticSearchIndices: { rest: "GET /deleteElasticSearchIndices", params: {},