🔧 Added an endpoint for searching issues via Elastic
This commit is contained in:
@@ -239,8 +239,9 @@ export default class ImportService extends Service {
|
|||||||
Comic.findByIdAndUpdate(
|
Comic.findByIdAndUpdate(
|
||||||
comicObjectId,
|
comicObjectId,
|
||||||
{
|
{
|
||||||
sourcedMetadata: {
|
$set: {
|
||||||
comicvine: matchedResult,
|
"sourcedMetadata.comicvine":
|
||||||
|
matchedResult,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{ new: true },
|
{ new: true },
|
||||||
@@ -347,7 +348,9 @@ export default class ImportService extends Service {
|
|||||||
$last: "$_id",
|
$last: "$_id",
|
||||||
},
|
},
|
||||||
count: { $sum: 1 },
|
count: { $sum: 1 },
|
||||||
data: { $push: "$$ROOT.sourcedMetadata.comicvine.volumeInformation" },
|
data: {
|
||||||
|
$push: "$$ROOT.sourcedMetadata.comicvine.volumeInformation",
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -490,6 +493,16 @@ export default class ImportService extends Service {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
issuesWithComicInfoXML: [
|
||||||
|
{
|
||||||
|
$match: {
|
||||||
|
"sourcedMetadata.comicInfo" : {
|
||||||
|
$exists: true,
|
||||||
|
$gt: {$size: 0}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
publisherWithMostComicsInLibrary: [
|
publisherWithMostComicsInLibrary: [
|
||||||
{
|
{
|
||||||
$unwind:
|
$unwind:
|
||||||
@@ -504,9 +517,7 @@ export default class ImportService extends Service {
|
|||||||
{ $sort: { count: -1 } },
|
{ $sort: { count: -1 } },
|
||||||
{ $limit: 1 },
|
{ $limit: 1 },
|
||||||
],
|
],
|
||||||
mostPopulatCharacter: [
|
mostPopulatCharacter: [],
|
||||||
|
|
||||||
]
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
@@ -517,7 +528,7 @@ export default class ImportService extends Service {
|
|||||||
};
|
};
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
flushDB: {
|
flushDB: {
|
||||||
rest: "POST /flushDB",
|
rest: "POST /flushDB",
|
||||||
params: {},
|
params: {},
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ export default class SettingsService extends Service {
|
|||||||
timeout: 400000,
|
timeout: 400000,
|
||||||
async handler(
|
async handler(
|
||||||
ctx: Context<{
|
ctx: Context<{
|
||||||
queryObjects: [],
|
queryObjects: [];
|
||||||
elasticSearchQueries: [
|
elasticSearchQueries: [
|
||||||
{
|
{
|
||||||
elasticSearchQuery: object;
|
elasticSearchQuery: object;
|
||||||
@@ -54,11 +54,39 @@ export default class SettingsService extends Service {
|
|||||||
|
|
||||||
body.responses.forEach((match) => {
|
body.responses.forEach((match) => {
|
||||||
console.log(match.hits.hits);
|
console.log(match.hits.hits);
|
||||||
})
|
});
|
||||||
|
|
||||||
return body.responses;
|
return body.responses;
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
issue: {
|
||||||
|
rest: "POST /searchIssue",
|
||||||
|
params: {},
|
||||||
|
handler: async (
|
||||||
|
ctx: Context<{
|
||||||
|
queryObject: {
|
||||||
|
volumeName: string;
|
||||||
|
issueNumber: string;
|
||||||
|
};
|
||||||
|
}>
|
||||||
|
) => {
|
||||||
|
console.log(ctx.params);
|
||||||
|
const result = await eSClient.search({
|
||||||
|
index: "comics",
|
||||||
|
body: {
|
||||||
|
query: {
|
||||||
|
match: {
|
||||||
|
"rawFileDetails.name":
|
||||||
|
ctx.params.queryObject
|
||||||
|
.volumeName,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
const { hits } = result.body;
|
||||||
|
return hits;
|
||||||
|
},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
methods: {},
|
methods: {},
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -190,7 +190,9 @@ export const extractComicInfoXMLFromRar = async (
|
|||||||
data: fileBuffer,
|
data: fileBuffer,
|
||||||
});
|
});
|
||||||
|
|
||||||
const extracted = extractor.extract({ files: ["ComicInfo.xml"] });
|
const extracted = extractor.extract({
|
||||||
|
files: ({ name }) => name.toLowerCase() === 'comicinfo.xml',
|
||||||
|
});
|
||||||
const files = [...extracted.files]; //load the files
|
const files = [...extracted.files]; //load the files
|
||||||
if (!isUndefined(files[0])) {
|
if (!isUndefined(files[0])) {
|
||||||
console.log(
|
console.log(
|
||||||
|
|||||||
Reference in New Issue
Block a user