🪵 Turned off logging to a file.

This commit is contained in:
2022-07-21 07:09:53 -07:00
parent a45fb1c2e7
commit 13e420e39c
3 changed files with 78 additions and 42 deletions

View File

@@ -57,25 +57,25 @@ const brokerConfig: BrokerOptions = {
autoPadding: false, autoPadding: false,
}, },
}, },
{ // {
type: "File", // type: "File",
options: { // options: {
level: "debug", // level: "debug",
folder: "./logs", // folder: "./logs",
filename: "threetwo-import-service.log", // filename: "threetwo-import-service.log",
// Using colors on the output // // Using colors on the output
colors: true, // colors: true,
// Print module names with different colors (like docker-compose for containers) // // Print module names with different colors (like docker-compose for containers)
moduleColors: false, // moduleColors: false,
// Line formatter. It can be "json", "short", "simple", "full", a `Function` or a template string like "{timestamp} {level} {nodeID}/{mod}: {msg}" // // Line formatter. It can be "json", "short", "simple", "full", a `Function` or a template string like "{timestamp} {level} {nodeID}/{mod}: {msg}"
formatter: "full", // formatter: "full",
// Custom object printer. If not defined, it uses the `util.inspect` method. // // Custom object printer. If not defined, it uses the `util.inspect` method.
objectPrinter: null, // objectPrinter: null,
eol: "\n", // eol: "\n",
// Auto-padding the module name in order to messages begin at the same column. // // Auto-padding the module name in order to messages begin at the same column.
autoPadding: true, // autoPadding: true,
}, // },
}, // },
], ],
// Default log level for built-in console logger. It can be overwritten in logger options above. // Default log level for built-in console logger. It can be overwritten in logger options above.
// Available values: trace, debug, info, warn, error, fatal // Available values: trace, debug, info, warn, error, fatal

View File

@@ -167,7 +167,7 @@ export default class ImportService extends Service {
params: {}, params: {},
async handler( async handler(
ctx: Context<{ ctx: Context<{
_id: string, _id: string;
sourcedMetadata: { sourcedMetadata: {
comicvine?: { comicvine?: {
volume: { api_detail_url: string }; volume: { api_detail_url: string };
@@ -229,7 +229,7 @@ export default class ImportService extends Service {
500 500
); );
} }
}, }
); );
} catch (error) { } catch (error) {
throw new Errors.MoleculerError( throw new Errors.MoleculerError(
@@ -343,10 +343,10 @@ export default class ImportService extends Service {
comicObjectId: string; comicObjectId: string;
comicObject: { comicObject: {
acquisition: { acquisition: {
source:{ source: {
wanted: boolean; wanted: boolean;
} };
} };
}; };
downloadStatus: { name: string }; downloadStatus: { name: string };
}> }>
@@ -354,8 +354,11 @@ export default class ImportService extends Service {
const result = await extractFromArchive( const result = await extractFromArchive(
`${COMICS_DIRECTORY}/${ctx.params.downloadStatus.name}` `${COMICS_DIRECTORY}/${ctx.params.downloadStatus.name}`
); );
Object.assign(ctx.params.comicObject, { rawFileDetails: result }); Object.assign(ctx.params.comicObject, {
ctx.params.comicObject.acquisition.source.wanted = false; rawFileDetails: result,
});
ctx.params.comicObject.acquisition.source.wanted =
false;
const updateResult = await Comic.findOneAndUpdate( const updateResult = await Comic.findOneAndUpdate(
{ _id: new ObjectId(ctx.params.comicObjectId) }, { _id: new ObjectId(ctx.params.comicObjectId) },
ctx.params.comicObject, 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: { libraryStatistics: {
rest: "GET /libraryStatistics", rest: "GET /libraryStatistics",
params: {}, params: {},

View File

@@ -9,7 +9,7 @@ import {
import { DbMixin } from "../mixins/db.mixin"; import { DbMixin } from "../mixins/db.mixin";
import Comic from "../models/comic.model"; 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"; import { eSClient } from "../models/comic.model";
const s = eSClient.helpers.msearch(); const s = eSClient.helpers.msearch();
@@ -113,12 +113,14 @@ export default class SettingsService extends Service {
case "volumes": case "volumes":
Object.assign(eSQuery, { Object.assign(eSQuery, {
exists: { exists: {
field: "sourcedMetadata.comicvine.volumeInformation" field: "sourcedMetadata.comicvine.volumeInformation",
} },
}); });
break; break;
} }
console.log("Searching ElasticSearch index with this query -> "); console.log(
"Searching ElasticSearch index with this query -> "
);
console.log( console.log(
JSON.stringify(eSQuery, null, 2) 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: { deleteElasticSearchIndices: {
rest: "GET /deleteElasticSearchIndices", rest: "GET /deleteElasticSearchIndices",
params: {}, params: {},