Added Freaky Fembots to Team Skeet.
This commit is contained in:
100
src/tools/manticore-actors.js
Normal file
100
src/tools/manticore-actors.js
Normal file
@@ -0,0 +1,100 @@
|
||||
'use strict';
|
||||
|
||||
const config = require('config');
|
||||
const manticore = require('manticoresearch');
|
||||
const args = require('yargs').argv;
|
||||
|
||||
const knex = require('../knex');
|
||||
|
||||
const mantiClient = new manticore.ApiClient();
|
||||
|
||||
mantiClient.basePath = `http://${config.database.manticore.host}:${config.database.manticore.httpPort}`;
|
||||
|
||||
const searchApi = new manticore.SearchApi(mantiClient);
|
||||
|
||||
const utilsApi = new manticore.UtilsApi(mantiClient);
|
||||
const indexApi = new manticore.IndexApi(mantiClient);
|
||||
|
||||
const update = args.update;
|
||||
|
||||
async function fetchActors() {
|
||||
// manually select date of birth, otherwise it is retrieved in local timezone but interpreted as UTC...
|
||||
const actors = await knex.raw(`
|
||||
SELECT actors.*, date_of_birth AT TIME ZONE 'Europe/Amsterdam' AT TIME ZONE 'UTC' as dob
|
||||
FROM actors
|
||||
GROUP BY actors.id;
|
||||
`);
|
||||
|
||||
return actors.rows;
|
||||
}
|
||||
|
||||
async function init() {
|
||||
if (update) {
|
||||
await utilsApi.sql('drop table actors');
|
||||
await utilsApi.sql(`create table actors(
|
||||
id int,
|
||||
name text,
|
||||
slug string,
|
||||
gender string,
|
||||
date_of_birth timestamp,
|
||||
country string,
|
||||
has_avatar bool,
|
||||
weight int,
|
||||
height int,
|
||||
cup string,
|
||||
natural_boobs int,
|
||||
penis_length int,
|
||||
penis_girth int
|
||||
)`);
|
||||
|
||||
const actors = await fetchActors();
|
||||
|
||||
const docs = actors.map((actor) => ({
|
||||
insert: {
|
||||
index: 'actors',
|
||||
id: actor.id,
|
||||
doc: {
|
||||
name: actor.name,
|
||||
slug: actor.slug,
|
||||
gender: actor.gender || undefined,
|
||||
date_of_birth: actor.dob ? Math.round(actor.dob.getTime() / 1000) : undefined,
|
||||
has_avatar: !!actor.avatar_media_id,
|
||||
country: actor.birth_country_alpha2 || undefined,
|
||||
height: actor.height || undefined,
|
||||
weight: actor.weight || undefined,
|
||||
cup: actor.cup || undefined,
|
||||
natural_boobs: actor.natural_boobs === null ? 0 : Number(actor.natural_boobs) + 1, // manticore bool does not seem to support null, and we need three states for natural_boobs: yes, no and unknown
|
||||
penis_length: actor.penis_length || undefined,
|
||||
penis_girth: actor.penis_girth || undefined,
|
||||
},
|
||||
},
|
||||
}));
|
||||
|
||||
const data = await indexApi.bulk(docs.map((doc) => JSON.stringify(doc)).join('\n')).catch((error) => {
|
||||
console.log(error);
|
||||
});
|
||||
|
||||
console.log('data', data);
|
||||
knex.destroy();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
const result = await searchApi.search({
|
||||
index: 'actors',
|
||||
query: {
|
||||
equals: {
|
||||
has_avatar: 1,
|
||||
},
|
||||
},
|
||||
limit: 3,
|
||||
sort: [{ slug: 'asc' }],
|
||||
});
|
||||
|
||||
console.log(result);
|
||||
console.log(result.hits?.hits);
|
||||
|
||||
knex.destroy();
|
||||
}
|
||||
|
||||
init();
|
||||
Reference in New Issue
Block a user