Integrated channel filter, partially restored actor bio.

This commit is contained in:
2024-01-10 02:00:38 +01:00
parent d242eb3b73
commit 63f2bdbe60
19 changed files with 1221 additions and 159 deletions

View File

@@ -1,4 +1,5 @@
import { differenceInYears } from 'date-fns';
import { unit } from 'mathjs';
import knex from './knex.js';
import { searchApi } from './manticore.js';
@@ -15,13 +16,36 @@ export function curateActor(actor, context = {}) {
dateOfBirth: actor.date_of_birth,
ageFromBirth: actor.date_of_birth && differenceInYears(Date.now(), actor.date_of_birth),
ageThen: context.sceneDate && actor.date_of_birth && differenceInYears(context.sceneDate, actor.date_of_birth),
birthCountry: actor.birth_country_alpha2 && {
alpha2: actor.birth_country_alpha2,
name: actor.birth_country_name,
bust: actor.bust,
cup: actor.cup,
waist: actor.waist,
hip: actor.hip,
naturalBoobs: actor.naturalBoobs,
height: actor.height && {
metric: actor.height,
imperial: unit(actor.height, 'cm').splitUnit(['ft', 'in']).map((value) => Math.round(value.toNumber())),
},
residenceCountry: actor.residence_country_alpha2 && {
alpha2: actor.residence_country_alpha2,
name: actor.residence_country_name,
weight: actor.weight && {
metric: actor.weight,
imperial: Math.round(unit(actor.weight, 'kg').toNumeric('lbs')),
},
eyes: actor.eyes,
hairColor: actor.hairColor,
hasTattoos: actor.has_tattoos,
tattoos: actor.tattoos,
hasPiercings: actor.has_piercings,
piercings: actor.piercings,
origin: {
country: actor.birth_country_alpha2 && {
alpha2: actor.birth_country_alpha2,
name: actor.birth_country_name,
},
},
residence: {
country: actor.residence_country_alpha2 && {
alpha2: actor.residence_country_alpha2,
name: actor.residence_country_name,
},
},
avatar: actor.avatar && {
id: actor.avatar.id,
@@ -30,6 +54,8 @@ export function curateActor(actor, context = {}) {
lazy: actor.avatar.lazy,
isS3: actor.avatar.is_s3,
},
createdAt: actor.created_at,
updatedAt: actor.updated_at,
likes: actor.stashed,
...context.append?.[actor.id],
};
@@ -90,8 +116,6 @@ function curateOptions(options) {
}
function buildQuery(filters) {
console.log('filters', filters);
const query = {
bool: {
must: [],
@@ -103,8 +127,6 @@ function buildQuery(filters) {
};
if (filters.query) {
console.log(filters.query);
query.bool.must.push({
match: {
name: filters.query,
@@ -224,8 +246,6 @@ export async function fetchActors(filters, rawOptions) {
const options = curateOptions(rawOptions);
const { query, expressions } = buildQuery(filters);
console.log(options);
const result = await searchApi.search({
index: 'actors',
query,