forked from DebaucheryLibrarian/traxxx
Added Manticore migration and meta text field.
This commit is contained in:
parent
86ffcc3316
commit
d9d585d51a
|
@ -0,0 +1,35 @@
|
|||
const config = require('config');
|
||||
const manticore = require('manticoresearch');
|
||||
|
||||
const mantiClient = new manticore.ApiClient();
|
||||
|
||||
mantiClient.basePath = `http://${config.database.manticore.host}:${config.database.manticore.httpPort}`;
|
||||
|
||||
const utilsApi = new manticore.UtilsApi(mantiClient);
|
||||
|
||||
exports.up = async () => {
|
||||
await utilsApi.sql(`create table scenes (
|
||||
id int,
|
||||
title text,
|
||||
entry_id text,
|
||||
channel_id int,
|
||||
channel_name text,
|
||||
channel_slug text,
|
||||
network_id int,
|
||||
network_name text,
|
||||
network_slug text,
|
||||
actor_ids multi,
|
||||
actors text,
|
||||
tag_ids multi,
|
||||
tags text,
|
||||
meta text,
|
||||
date timestamp,
|
||||
created_at timestamp,
|
||||
effective_date timestamp,
|
||||
stashed int
|
||||
)`);
|
||||
};
|
||||
|
||||
exports.down = async () => {
|
||||
await utilsApi.sql('drop table scenes');
|
||||
};
|
|
@ -81,6 +81,7 @@ async function init() {
|
|||
actors text,
|
||||
tag_ids multi,
|
||||
tags text,
|
||||
meta text,
|
||||
date timestamp,
|
||||
created_at timestamp,
|
||||
effective_date timestamp,
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
'use strict';
|
||||
|
||||
const manticore = require('manticoresearch');
|
||||
const { format } = require('date-fns');
|
||||
|
||||
const knex = require('./knex');
|
||||
const logger = require('./logger')(__filename);
|
||||
|
@ -54,9 +55,6 @@ async function updateManticoreSearch(releaseIds) {
|
|||
parents.alias;
|
||||
`, releaseIds && [releaseIds]);
|
||||
|
||||
console.log(releaseIds);
|
||||
console.log(scenes);
|
||||
|
||||
const docs = scenes.rows.map((scene) => ({
|
||||
replace: {
|
||||
index: 'scenes',
|
||||
|
@ -77,20 +75,17 @@ async function updateManticoreSearch(releaseIds) {
|
|||
actors: scene.actors.map((actor) => actor.f2).join(),
|
||||
tag_ids: scene.tags.map((tag) => tag.f1),
|
||||
tags: scene.tags.map((tag) => tag.f2).join(),
|
||||
meta: scene.date ? format(scene.date, 'y M d') : undefined,
|
||||
stashed: scene.stashed || 0,
|
||||
},
|
||||
},
|
||||
}));
|
||||
|
||||
console.log('docs', docs);
|
||||
|
||||
if (docs.length === 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
const data = await indexApi.bulk(docs.map((doc) => JSON.stringify(doc)).join('\n'));
|
||||
|
||||
console.log('data', data);
|
||||
await indexApi.bulk(docs.map((doc) => JSON.stringify(doc)).join('\n'));
|
||||
}
|
||||
|
||||
async function updateSqlSearch(releaseIds) {
|
||||
|
|
Loading…
Reference in New Issue