forked from DebaucheryLibrarian/traxxx
Added entity_ids column to manticore scenes table.
This commit is contained in:
parent
7171ac9252
commit
f1f618d3a7
|
@ -18,6 +18,7 @@ const scenesFields = `
|
||||||
network_id int,
|
network_id int,
|
||||||
network_name text,
|
network_name text,
|
||||||
network_slug text,
|
network_slug text,
|
||||||
|
entity_ids multi,
|
||||||
actor_ids multi,
|
actor_ids multi,
|
||||||
actors text,
|
actors text,
|
||||||
tag_ids multi,
|
tag_ids multi,
|
||||||
|
|
|
@ -11,8 +11,6 @@ const mantiClient = new manticore.ApiClient();
|
||||||
|
|
||||||
mantiClient.basePath = `http://${config.database.manticore.host}:${config.database.manticore.httpPort}`;
|
mantiClient.basePath = `http://${config.database.manticore.host}:${config.database.manticore.httpPort}`;
|
||||||
|
|
||||||
const searchApi = new manticore.SearchApi(mantiClient);
|
|
||||||
|
|
||||||
const utilsApi = new manticore.UtilsApi(mantiClient);
|
const utilsApi = new manticore.UtilsApi(mantiClient);
|
||||||
const indexApi = new manticore.IndexApi(mantiClient);
|
const indexApi = new manticore.IndexApi(mantiClient);
|
||||||
|
|
||||||
|
@ -80,12 +78,14 @@ async function init() {
|
||||||
network_id int,
|
network_id int,
|
||||||
network_name text,
|
network_name text,
|
||||||
network_slug text,
|
network_slug text,
|
||||||
|
entity_ids multi,
|
||||||
actor_ids multi,
|
actor_ids multi,
|
||||||
actors text,
|
actors text,
|
||||||
tag_ids multi,
|
tag_ids multi,
|
||||||
tags text,
|
tags text,
|
||||||
meta text,
|
meta text,
|
||||||
date timestamp,
|
date timestamp,
|
||||||
|
is_showcased bool,
|
||||||
created_at timestamp,
|
created_at timestamp,
|
||||||
effective_date timestamp,
|
effective_date timestamp,
|
||||||
stashed int
|
stashed int
|
||||||
|
@ -115,6 +115,7 @@ async function init() {
|
||||||
network_id: scene.network_id || undefined,
|
network_id: scene.network_id || undefined,
|
||||||
network_slug: scene.network_slug || undefined,
|
network_slug: scene.network_slug || undefined,
|
||||||
network_name: scene.network_name || undefined,
|
network_name: scene.network_name || undefined,
|
||||||
|
entity_ids: [scene.channel_id, scene.network_id], // manticore does not support OR, this allows IN
|
||||||
actor_ids: scene.actors.map((actor) => actor.f1),
|
actor_ids: scene.actors.map((actor) => actor.f1),
|
||||||
actors: scene.actors.map((actor) => actor.f2).join(),
|
actors: scene.actors.map((actor) => actor.f2).join(),
|
||||||
tag_ids: scene.tags.map((tag) => tag.f1),
|
tag_ids: scene.tags.map((tag) => tag.f1),
|
||||||
|
@ -131,136 +132,6 @@ async function init() {
|
||||||
console.log('data', data);
|
console.log('data', data);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
const searchRequest = new manticore.SearchRequest();
|
|
||||||
|
|
||||||
searchRequest.index = 'scenes';
|
|
||||||
searchRequest.attr_filter = new manticore.InFilter('ratings', [600]);
|
|
||||||
|
|
||||||
const result = await searchApi.search(searchRequest);
|
|
||||||
*/
|
|
||||||
|
|
||||||
const result = await searchApi.search({
|
|
||||||
index: 'scenes',
|
|
||||||
query: {
|
|
||||||
bool: {
|
|
||||||
must: [
|
|
||||||
/*
|
|
||||||
{
|
|
||||||
match: {
|
|
||||||
'*': 'going-all-out-with-a-gangbang_1080p.mp4',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
*/
|
|
||||||
{
|
|
||||||
range: {
|
|
||||||
effective_date: {
|
|
||||||
lte: Math.round(Date.now() / 1000),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
/*
|
|
||||||
{
|
|
||||||
equals: {
|
|
||||||
actor_ids: 81930,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
*/
|
|
||||||
],
|
|
||||||
must_not: [
|
|
||||||
{
|
|
||||||
in: {
|
|
||||||
tag_ids: [101, 180, 32],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
limit: 30,
|
|
||||||
sort: [{ effective_date: 'desc' }],
|
|
||||||
/*
|
|
||||||
aggs: {
|
|
||||||
tags: {
|
|
||||||
terms: {
|
|
||||||
field: 'tag_ids',
|
|
||||||
size: 100,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
actors: {
|
|
||||||
terms: {
|
|
||||||
field: 'actor_ids',
|
|
||||||
size: 100,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
*/
|
|
||||||
});
|
|
||||||
|
|
||||||
console.log(result);
|
|
||||||
|
|
||||||
/*
|
|
||||||
if (result.hits) {
|
|
||||||
result.hits.hits.map((hit) => console.log(hit));
|
|
||||||
|
|
||||||
// console.log(result.aggregations.actors);
|
|
||||||
// console.log(result.aggregations.tags);
|
|
||||||
|
|
||||||
const sceneIds = result.hits.hits.map((hit) => hit._id);
|
|
||||||
|
|
||||||
console.time('fetch');
|
|
||||||
|
|
||||||
const [scenes, actors, tags, posters, photos] = await Promise.all([
|
|
||||||
knex('releases').whereIn('id', sceneIds),
|
|
||||||
knex('releases_actors')
|
|
||||||
.whereIn('release_id', sceneIds)
|
|
||||||
.leftJoin('actors', 'actors.id', 'releases_actors.actor_id'),
|
|
||||||
knex('releases_tags')
|
|
||||||
.whereIn('release_id', sceneIds)
|
|
||||||
.leftJoin('tags', 'tags.id', 'releases_tags.tag_id'),
|
|
||||||
knex('releases_posters')
|
|
||||||
.whereIn('release_id', sceneIds)
|
|
||||||
.leftJoin('media', 'media.id', 'releases_posters.media_id'),
|
|
||||||
knex('releases_photos')
|
|
||||||
.whereIn('release_id', sceneIds)
|
|
||||||
.leftJoin('media', 'media.id', 'releases_photos.media_id'),
|
|
||||||
]);
|
|
||||||
|
|
||||||
console.timeEnd('fetch');
|
|
||||||
|
|
||||||
console.time('join');
|
|
||||||
|
|
||||||
const joinedScenes = await knex('releases')
|
|
||||||
.select(knex.raw(`
|
|
||||||
releases.*,
|
|
||||||
COALESCE(json_agg(DISTINCT actors) FILTER (WHERE actors.id IS NOT NULL), '[]') as actors,
|
|
||||||
COALESCE(json_agg(DISTINCT tags) FILTER (WHERE tags.id IS NOT NULL), '[]') as tags,
|
|
||||||
COALESCE(json_agg(DISTINCT posters) FILTER (WHERE posters.id IS NOT NULL), '[]') as posters,
|
|
||||||
COALESCE(json_agg(DISTINCT photos) FILTER (WHERE photos.id IS NOT NULL), '[]') as photos
|
|
||||||
`))
|
|
||||||
.whereIn('releases.id', sceneIds)
|
|
||||||
.leftJoin('releases_actors', 'releases_actors.release_id', 'releases.id')
|
|
||||||
.leftJoin('actors', 'actors.id', 'releases_actors.actor_id')
|
|
||||||
.leftJoin('releases_tags', 'releases_tags.release_id', 'releases.id')
|
|
||||||
.leftJoin('tags', 'tags.id', 'releases_tags.tag_id')
|
|
||||||
.leftJoin('releases_posters', 'releases_posters.release_id', 'releases.id')
|
|
||||||
.leftJoin('media as posters', 'posters.id', 'releases_posters.media_id')
|
|
||||||
.leftJoin('releases_photos', 'releases_photos.release_id', 'releases.id')
|
|
||||||
.leftJoin('media as photos', 'photos.id', 'releases_photos.media_id')
|
|
||||||
.groupBy('releases.id');
|
|
||||||
|
|
||||||
// console.log(joinedScenes[0]);
|
|
||||||
|
|
||||||
console.timeEnd('join');
|
|
||||||
|
|
||||||
console.log(sceneIds);
|
|
||||||
console.log(scenes);
|
|
||||||
console.log(actors);
|
|
||||||
console.log(tags);
|
|
||||||
console.log(posters);
|
|
||||||
console.log(photos);
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
knex.destroy();
|
knex.destroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -133,6 +133,7 @@ async function updateManticoreSceneSearch(releaseIds) {
|
||||||
network_id: scene.network_id || undefined,
|
network_id: scene.network_id || undefined,
|
||||||
network_slug: scene.network_slug || undefined,
|
network_slug: scene.network_slug || undefined,
|
||||||
network_name: scene.network_name || undefined,
|
network_name: scene.network_name || undefined,
|
||||||
|
entity_ids: [scene.channel_id, scene.network_id], // manticore does not support OR, this allows IN
|
||||||
actor_ids: scene.actors.map((actor) => actor.f1),
|
actor_ids: scene.actors.map((actor) => actor.f1),
|
||||||
actors: scene.actors.map((actor) => actor.f2).join(),
|
actors: scene.actors.map((actor) => actor.f2).join(),
|
||||||
tag_ids: scene.tags.map((tag) => tag.f1),
|
tag_ids: scene.tags.map((tag) => tag.f1),
|
||||||
|
|
Loading…
Reference in New Issue