📚 Changes to CV model
This commit is contained in:
@@ -1,6 +1,5 @@
|
|||||||
const paginate = require("mongoose-paginate-v2");
|
const paginate = require("mongoose-paginate-v2");
|
||||||
const { Client } = require("@elastic/elasticsearch");
|
const { Client } = require("@elastic/elasticsearch");
|
||||||
import ComicVineMetadataSchema from "./comicvine.metadata.model";
|
|
||||||
import { mongoosastic } from "mongoosastic-ts";
|
import { mongoosastic } from "mongoosastic-ts";
|
||||||
const mongoose = require("mongoose");
|
const mongoose = require("mongoose");
|
||||||
import {
|
import {
|
||||||
@@ -56,6 +55,29 @@ const DirectConnectBundleSchema = mongoose.Schema({
|
|||||||
size: String,
|
size: String,
|
||||||
type: {},
|
type: {},
|
||||||
});
|
});
|
||||||
|
const wantedSchema = new mongoose.Schema({
|
||||||
|
source: { type: String, default: null },
|
||||||
|
markEntireVolumeWanted: Boolean,
|
||||||
|
issues: {
|
||||||
|
type: [
|
||||||
|
{
|
||||||
|
id: Number,
|
||||||
|
url: String,
|
||||||
|
image: { type: Array, default: [] },
|
||||||
|
},
|
||||||
|
],
|
||||||
|
default: null, // Set default to null for issues
|
||||||
|
},
|
||||||
|
volume: {
|
||||||
|
type: {
|
||||||
|
id: Number,
|
||||||
|
url: String,
|
||||||
|
image: { type: Array, default: [] },
|
||||||
|
name: String,
|
||||||
|
},
|
||||||
|
default: null, // Set default to null for volume
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
const ComicSchema = mongoose.Schema(
|
const ComicSchema = mongoose.Schema(
|
||||||
{
|
{
|
||||||
@@ -72,7 +94,7 @@ const ComicSchema = mongoose.Schema(
|
|||||||
sourcedMetadata: {
|
sourcedMetadata: {
|
||||||
comicInfo: { type: mongoose.Schema.Types.Mixed, default: {} },
|
comicInfo: { type: mongoose.Schema.Types.Mixed, default: {} },
|
||||||
comicvine: {
|
comicvine: {
|
||||||
type: ComicVineMetadataSchema,
|
type: Object,
|
||||||
es_indexed: true,
|
es_indexed: true,
|
||||||
default: {},
|
default: {},
|
||||||
},
|
},
|
||||||
@@ -102,11 +124,9 @@ const ComicSchema = mongoose.Schema(
|
|||||||
subtitle: { type: String, es_indexed: true },
|
subtitle: { type: String, es_indexed: true },
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
wanted: wantedSchema,
|
||||||
|
|
||||||
acquisition: {
|
acquisition: {
|
||||||
source: {
|
|
||||||
wanted: Boolean,
|
|
||||||
name: String,
|
|
||||||
},
|
|
||||||
release: {},
|
release: {},
|
||||||
directconnect: {
|
directconnect: {
|
||||||
downloads: {
|
downloads: {
|
||||||
|
|||||||
@@ -1,95 +0,0 @@
|
|||||||
const mongoose = require("mongoose");
|
|
||||||
const Things = mongoose.Schema({
|
|
||||||
_id: false,
|
|
||||||
api_detail_url: String,
|
|
||||||
id: Number,
|
|
||||||
name: String,
|
|
||||||
site_detail_url: String,
|
|
||||||
count: String,
|
|
||||||
});
|
|
||||||
const Issue = mongoose.Schema({
|
|
||||||
_id: false,
|
|
||||||
api_detail_url: String,
|
|
||||||
id: Number,
|
|
||||||
name: String,
|
|
||||||
issue_number: String,
|
|
||||||
});
|
|
||||||
const VolumeInformation = mongoose.Schema({
|
|
||||||
_id: false,
|
|
||||||
aliases: [String],
|
|
||||||
api_detail_url: String,
|
|
||||||
characters: [Things],
|
|
||||||
concepts: [Things],
|
|
||||||
count_of_issues: String,
|
|
||||||
date_added: String,
|
|
||||||
date_last_updated: String,
|
|
||||||
deck: String,
|
|
||||||
description: String,
|
|
||||||
first_issue: Issue,
|
|
||||||
id: Number,
|
|
||||||
image: {
|
|
||||||
icon_url: String,
|
|
||||||
medium_url: String,
|
|
||||||
screen_url: String,
|
|
||||||
screen_large_url: String,
|
|
||||||
small_url: String,
|
|
||||||
super_url: String,
|
|
||||||
thumb_url: String,
|
|
||||||
tiny_url: String,
|
|
||||||
original_url: String,
|
|
||||||
image_tags: String,
|
|
||||||
},
|
|
||||||
issues: [
|
|
||||||
{
|
|
||||||
api_detail_url: String,
|
|
||||||
id: Number,
|
|
||||||
name: String,
|
|
||||||
issue_number: String,
|
|
||||||
site_detail_url: String,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
last_issue: Issue,
|
|
||||||
locations: [Things],
|
|
||||||
name: String,
|
|
||||||
objects: [Things],
|
|
||||||
people: [Things],
|
|
||||||
publisher: {
|
|
||||||
api_detail_url: String,
|
|
||||||
id: Number,
|
|
||||||
name: String,
|
|
||||||
},
|
|
||||||
site_detail_url: String,
|
|
||||||
start_year: String,
|
|
||||||
});
|
|
||||||
|
|
||||||
const ComicVineMetadataSchema = mongoose.Schema({
|
|
||||||
_id: false,
|
|
||||||
aliases: [String],
|
|
||||||
api_detail_url: String,
|
|
||||||
has_staff_review: { type: mongoose.Schema.Types.Mixed },
|
|
||||||
|
|
||||||
cover_date: Date,
|
|
||||||
date_added: String,
|
|
||||||
date_last_updated: String,
|
|
||||||
deck: String,
|
|
||||||
description: String,
|
|
||||||
image: {
|
|
||||||
icon_url: String,
|
|
||||||
medium_url: String,
|
|
||||||
screen_url: String,
|
|
||||||
screen_large_url: String,
|
|
||||||
small_url: String,
|
|
||||||
super_url: String,
|
|
||||||
thumb_url: String,
|
|
||||||
tiny_url: String,
|
|
||||||
original_url: String,
|
|
||||||
image_tags: String,
|
|
||||||
},
|
|
||||||
|
|
||||||
id: Number,
|
|
||||||
name: String,
|
|
||||||
resource_type: String,
|
|
||||||
volumeInformation: VolumeInformation,
|
|
||||||
});
|
|
||||||
|
|
||||||
export default ComicVineMetadataSchema;
|
|
||||||
@@ -117,7 +117,7 @@ export default class ImportService extends Service {
|
|||||||
filePath: ctx.params.filePath,
|
filePath: ctx.params.filePath,
|
||||||
comicObjectId: ctx.params.comicObjectId,
|
comicObjectId: ctx.params.comicObjectId,
|
||||||
options: ctx.params.options,
|
options: ctx.params.options,
|
||||||
queueName: "uncompressFullArchive.async",
|
action: "uncompressFullArchive.async",
|
||||||
description: `Job for uncompressing archive at ${ctx.params.filePath}`,
|
description: `Job for uncompressing archive at ${ctx.params.filePath}`,
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
@@ -260,11 +260,13 @@ export default class ImportService extends Service {
|
|||||||
rawFileDetails: {
|
rawFileDetails: {
|
||||||
name: string;
|
name: string;
|
||||||
};
|
};
|
||||||
|
wanted: {
|
||||||
|
issues: [];
|
||||||
|
volume: {};
|
||||||
|
source: string;
|
||||||
|
markEntireVolumeWanted: Boolean;
|
||||||
|
};
|
||||||
acquisition: {
|
acquisition: {
|
||||||
source: {
|
|
||||||
wanted: boolean;
|
|
||||||
name?: string;
|
|
||||||
};
|
|
||||||
directconnect: {
|
directconnect: {
|
||||||
downloads: [];
|
downloads: [];
|
||||||
};
|
};
|
||||||
@@ -275,27 +277,6 @@ export default class ImportService extends Service {
|
|||||||
try {
|
try {
|
||||||
let volumeDetails;
|
let volumeDetails;
|
||||||
const comicMetadata = ctx.params.payload;
|
const comicMetadata = ctx.params.payload;
|
||||||
// When an issue is added from the search CV feature
|
|
||||||
// we solicit volume information and add that to mongo
|
|
||||||
if (
|
|
||||||
comicMetadata.sourcedMetadata.comicvine &&
|
|
||||||
!isNil(
|
|
||||||
comicMetadata.sourcedMetadata.comicvine
|
|
||||||
.volume
|
|
||||||
)
|
|
||||||
) {
|
|
||||||
volumeDetails = await this.broker.call(
|
|
||||||
"comicvine.getVolumes",
|
|
||||||
{
|
|
||||||
volumeURI:
|
|
||||||
comicMetadata.sourcedMetadata
|
|
||||||
.comicvine.volume
|
|
||||||
.api_detail_url,
|
|
||||||
}
|
|
||||||
);
|
|
||||||
comicMetadata.sourcedMetadata.comicvine.volumeInformation =
|
|
||||||
volumeDetails.results;
|
|
||||||
}
|
|
||||||
|
|
||||||
console.log("Saving to Mongo...");
|
console.log("Saving to Mongo...");
|
||||||
console.log(
|
console.log(
|
||||||
|
|||||||
@@ -100,12 +100,19 @@ export default class SettingsService extends Service {
|
|||||||
case "wanted":
|
case "wanted":
|
||||||
Object.assign(eSQuery, {
|
Object.assign(eSQuery, {
|
||||||
bool: {
|
bool: {
|
||||||
must: {
|
should: [
|
||||||
term: {
|
{
|
||||||
"acquisition.source.wanted":
|
exists: {
|
||||||
true,
|
field: "wanted.issues",
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
{
|
||||||
|
exists: {
|
||||||
|
field: "wanted.volume",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
minimum_should_match: 1,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
import axios from "axios";
|
|
||||||
import {
|
import {
|
||||||
Context,
|
Context,
|
||||||
Service,
|
Service,
|
||||||
@@ -9,8 +8,6 @@ import {
|
|||||||
} from "moleculer";
|
} from "moleculer";
|
||||||
import { DbMixin } from "../mixins/db.mixin";
|
import { DbMixin } from "../mixins/db.mixin";
|
||||||
import Comic from "../models/comic.model";
|
import Comic from "../models/comic.model";
|
||||||
const ObjectId = require("mongoose").Types.ObjectId;
|
|
||||||
import { isNil, isUndefined } from "lodash";
|
|
||||||
import BullMqMixin from "moleculer-bullmq";
|
import BullMqMixin from "moleculer-bullmq";
|
||||||
const { MoleculerError } = require("moleculer").Errors;
|
const { MoleculerError } = require("moleculer").Errors;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user