Added stashes to Manticore search update.
|
@ -7,6 +7,7 @@ data/
|
|||
tmp/*
|
||||
public/js/*
|
||||
public/css/*
|
||||
public/img/tags/
|
||||
config/*
|
||||
!config/default.js
|
||||
assets/js/config/
|
||||
|
|
|
@ -2,9 +2,9 @@ exports.up = async function up(knex) {
|
|||
await knex.raw(`
|
||||
CREATE MATERIALIZED VIEW actors_meta AS (
|
||||
SELECT
|
||||
actors.*,
|
||||
COUNT(DISTINCT stashes_actors) as stashed,
|
||||
COUNT(DISTINCT releases_actors) as scenes,
|
||||
actors.id as actor_id,
|
||||
COUNT(DISTINCT stashes_actors)::integer as stashed,
|
||||
COUNT(DISTINCT releases_actors)::integer as scenes,
|
||||
row_to_json(avatars) as avatar
|
||||
FROM actors
|
||||
LEFT JOIN stashes_actors ON stashes_actors.actor_id = actors.id
|
||||
|
@ -17,12 +17,31 @@ exports.up = async function up(knex) {
|
|||
|
||||
CREATE MATERIALIZED VIEW scenes_meta AS (
|
||||
SELECT
|
||||
releases.*,
|
||||
COUNT(DISTINCT stashes_scenes) as stashed
|
||||
releases.id as scene_id,
|
||||
COUNT(DISTINCT stashes_scenes)::integer as stashed
|
||||
FROM releases
|
||||
LEFT JOIN stashes_scenes ON stashes_scenes.scene_id = releases.id
|
||||
GROUP BY releases.id
|
||||
);
|
||||
|
||||
CREATE MATERIALIZED VIEW movies_meta AS (
|
||||
SELECT
|
||||
movie_id,
|
||||
stashed,
|
||||
stashed_scenes,
|
||||
stashed + stashed_scenes as stashed_total
|
||||
FROM (
|
||||
SELECT
|
||||
movies.id as movie_id,
|
||||
COUNT(DISTINCT stashes_movies)::integer as stashed,
|
||||
COUNT(DISTINCT stashes_scenes)::integer as stashed_scenes
|
||||
FROM movies
|
||||
LEFT JOIN stashes_movies ON stashes_movies.movie_id = movies.id
|
||||
LEFT JOIN movies_scenes ON movies_scenes.movie_id = movies.id
|
||||
LEFT JOIN stashes_scenes ON stashes_scenes.scene_id = movies_scenes.scene_id
|
||||
GROUP BY movies.id
|
||||
)
|
||||
);
|
||||
`);
|
||||
};
|
||||
|
||||
|
@ -30,5 +49,6 @@ exports.down = async function down(knex) {
|
|||
await knex.raw(`
|
||||
DROP MATERIALIZED VIEW IF EXISTS actors_meta;
|
||||
DROP MATERIALIZED VIEW IF EXISTS scenes_meta;
|
||||
DROP MATERIALIZED VIEW IF EXISTS movies_meta;
|
||||
`);
|
||||
};
|
||||
|
|
|
@ -7,30 +7,119 @@ mantiClient.basePath = `http://${config.database.manticore.host}:${config.databa
|
|||
|
||||
const utilsApi = new manticore.UtilsApi(mantiClient);
|
||||
|
||||
exports.up = async () => {
|
||||
await utilsApi.sql(`create table scenes (
|
||||
id int,
|
||||
title text,
|
||||
title_filtered text,
|
||||
shoot_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
|
||||
const scenesFields = `
|
||||
id int,
|
||||
title text,
|
||||
title_filtered text,
|
||||
shoot_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
|
||||
`;
|
||||
|
||||
const moviesFields = `
|
||||
id int,
|
||||
title text,
|
||||
title_filtered 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,
|
||||
has_cover bool,
|
||||
created_at timestamp,
|
||||
effective_date timestamp,
|
||||
stashed int,
|
||||
stashed_scenes int,
|
||||
stashed_total int
|
||||
`;
|
||||
|
||||
const actorsFields = `
|
||||
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,
|
||||
stashed int,
|
||||
scenes int
|
||||
`;
|
||||
|
||||
exports.up = async (knex) => {
|
||||
await utilsApi.sql(`create table scenes (${scenesFields})`);
|
||||
|
||||
/*
|
||||
await utilsApi.sql(`create table scenes_stashed (
|
||||
${scenesFields},
|
||||
user_id int,
|
||||
stash_id int
|
||||
)`);
|
||||
*/
|
||||
|
||||
await utilsApi.sql(`create table scenes_stashed (
|
||||
scene_id int,
|
||||
stash_id int,
|
||||
user_id int
|
||||
)`);
|
||||
|
||||
await utilsApi.sql(`create table movies (${moviesFields})`);
|
||||
|
||||
await utilsApi.sql(`create table movies_stashed (
|
||||
${moviesFields},
|
||||
user_id int,
|
||||
stash_id int
|
||||
)`);
|
||||
|
||||
await utilsApi.sql(`create table actors (${actorsFields})`);
|
||||
|
||||
await utilsApi.sql(`create table actors_stashed (
|
||||
${actorsFields},
|
||||
user_id int,
|
||||
stash_id int
|
||||
)`);
|
||||
|
||||
await knex.schema.alterTable('stashes_scenes', (table) => table.increments('id'));
|
||||
await knex.schema.alterTable('stashes_movies', (table) => table.increments('id'));
|
||||
await knex.schema.alterTable('stashes_actors', (table) => table.increments('id'));
|
||||
await knex.schema.alterTable('stashes_series', (table) => table.increments('id'));
|
||||
};
|
||||
|
||||
exports.down = async () => {
|
||||
await utilsApi.sql('drop table scenes');
|
||||
exports.down = async (knex) => {
|
||||
await utilsApi.sql('drop table if exists scenes');
|
||||
await utilsApi.sql('drop table if exists scenes_stashed');
|
||||
await utilsApi.sql('drop table if exists movies');
|
||||
await utilsApi.sql('drop table if exists movies_stashed');
|
||||
await utilsApi.sql('drop table if exists actors');
|
||||
await utilsApi.sql('drop table if exists actors_stashed');
|
||||
|
||||
await knex.schema.alterTable('stashes_scenes', (table) => table.dropColumn('id'));
|
||||
await knex.schema.alterTable('stashes_movies', (table) => table.dropColumn('id'));
|
||||
await knex.schema.alterTable('stashes_actors', (table) => table.dropColumn('id'));
|
||||
await knex.schema.alterTable('stashes_series', (table) => table.dropColumn('id'));
|
||||
};
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
exports.up = async (knex) => {
|
||||
await knex.schema.alterTable('users', (table) => {
|
||||
table.dropUnique('username');
|
||||
});
|
||||
|
||||
await knex.raw(`
|
||||
CREATE UNIQUE INDEX username_unique_index ON users (LOWER(username));
|
||||
CREATE UNIQUE INDEX email_unique_index ON users (LOWER(email));
|
||||
`);
|
||||
};
|
||||
|
||||
exports.down = async (knex) => {
|
||||
await knex.raw(`
|
||||
DROP INDEX IF EXISTS username_unique_index;
|
||||
DROP INDEX IF EXISTS email_unique_index;
|
||||
`);
|
||||
|
||||
await knex.schema.alterTable('users', (table) => {
|
||||
table.unique('username');
|
||||
});
|
||||
};
|
|
@ -0,0 +1,22 @@
|
|||
exports.up = async function up(knex) {
|
||||
await knex.raw(`
|
||||
CREATE MATERIALIZED VIEW stashes_meta AS (
|
||||
SELECT
|
||||
stashes.id as stash_id,
|
||||
COUNT(DISTINCT stashes_scenes)::integer as stashed_scenes,
|
||||
COUNT(DISTINCT stashes_movies)::integer as stashed_movies,
|
||||
COUNT(DISTINCT stashes_actors)::integer as stashed_actors
|
||||
FROM stashes
|
||||
LEFT JOIN stashes_scenes ON stashes_scenes.stash_id = stashes.id
|
||||
LEFT JOIN stashes_movies ON stashes_movies.stash_id = stashes.id
|
||||
LEFT JOIN stashes_actors ON stashes_actors.stash_id = stashes.id
|
||||
GROUP BY stashes.id
|
||||
);
|
||||
`);
|
||||
};
|
||||
|
||||
exports.down = async function down(knex) {
|
||||
await knex.raw(`
|
||||
DROP MATERIALIZED VIEW IF EXISTS stashes_meta;
|
||||
`);
|
||||
};
|
Before ![]() (image error) Size: 1.3 MiB |
Before ![]() (image error) Size: 1.2 MiB |
Before ![]() (image error) Size: 1.5 MiB |
Before ![]() (image error) Size: 846 KiB |
Before ![]() (image error) Size: 2.6 MiB |
Before ![]() (image error) Size: 6.7 KiB |
Before ![]() (image error) Size: 8.1 KiB |
Before ![]() (image error) Size: 7.8 KiB |
Before ![]() (image error) Size: 6.7 KiB |
Before ![]() (image error) Size: 8.9 KiB |
Before ![]() (image error) Size: 25 KiB |
Before ![]() (image error) Size: 35 KiB |
Before ![]() (image error) Size: 31 KiB |
Before ![]() (image error) Size: 25 KiB |
Before ![]() (image error) Size: 42 KiB |
Before ![]() (image error) Size: 845 KiB |
Before ![]() (image error) Size: 1.2 MiB |
Before ![]() (image error) Size: 410 KiB |
Before ![]() (image error) Size: 6.6 MiB |
Before ![]() (image error) Size: 111 KiB |
Before ![]() (image error) Size: 4.1 MiB |
Before ![]() (image error) Size: 1.1 MiB |
Before ![]() (image error) Size: 762 KiB |
Before ![]() (image error) Size: 689 KiB |
Before ![]() (image error) Size: 1.5 MiB |
Before ![]() (image error) Size: 1.5 MiB |
Before ![]() (image error) Size: 1.5 MiB |
Before ![]() (image error) Size: 2.1 MiB |
Before ![]() (image error) Size: 2.5 MiB |
Before ![]() (image error) Size: 1.3 MiB |
Before ![]() (image error) Size: 12 MiB |
Before ![]() (image error) Size: 12 MiB |
Before ![]() (image error) Size: 1.2 MiB |
Before ![]() (image error) Size: 546 KiB |
Before ![]() (image error) Size: 3.6 MiB |
Before ![]() (image error) Size: 823 KiB |
Before ![]() (image error) Size: 7.7 KiB |
Before ![]() (image error) Size: 8.6 KiB |
Before ![]() (image error) Size: 8.0 KiB |
Before ![]() (image error) Size: 8.7 KiB |
Before ![]() (image error) Size: 8.4 KiB |
Before ![]() (image error) Size: 6.8 KiB |
Before ![]() (image error) Size: 7.2 KiB |
Before ![]() (image error) Size: 8.1 KiB |
Before ![]() (image error) Size: 8.1 KiB |
Before ![]() (image error) Size: 7.8 KiB |
Before ![]() (image error) Size: 7.8 KiB |
Before ![]() (image error) Size: 7.1 KiB |
Before ![]() (image error) Size: 8.7 KiB |
Before ![]() (image error) Size: 7.2 KiB |
Before ![]() (image error) Size: 6.6 KiB |
Before ![]() (image error) Size: 7.1 KiB |
Before ![]() (image error) Size: 7.7 KiB |
Before ![]() (image error) Size: 7.0 KiB |
Before ![]() (image error) Size: 8.1 KiB |
Before ![]() (image error) Size: 8.5 KiB |
Before ![]() (image error) Size: 8.9 KiB |
Before ![]() (image error) Size: 6.9 KiB |
Before ![]() (image error) Size: 7.7 KiB |
Before ![]() (image error) Size: 8.0 KiB |
Before ![]() (image error) Size: 7.1 KiB |
Before ![]() (image error) Size: 7.0 KiB |
Before ![]() (image error) Size: 3.7 MiB |
Before ![]() (image error) Size: 868 KiB |
Before ![]() (image error) Size: 32 KiB |
Before ![]() (image error) Size: 39 KiB |
Before ![]() (image error) Size: 34 KiB |
Before ![]() (image error) Size: 36 KiB |
Before ![]() (image error) Size: 34 KiB |
Before ![]() (image error) Size: 28 KiB |
Before ![]() (image error) Size: 29 KiB |
Before ![]() (image error) Size: 33 KiB |
Before ![]() (image error) Size: 33 KiB |
Before ![]() (image error) Size: 32 KiB |
Before ![]() (image error) Size: 33 KiB |
Before ![]() (image error) Size: 29 KiB |
Before ![]() (image error) Size: 36 KiB |
Before ![]() (image error) Size: 32 KiB |
Before ![]() (image error) Size: 30 KiB |
Before ![]() (image error) Size: 31 KiB |
Before ![]() (image error) Size: 33 KiB |
Before ![]() (image error) Size: 33 KiB |
Before ![]() (image error) Size: 38 KiB |
Before ![]() (image error) Size: 41 KiB |
Before ![]() (image error) Size: 42 KiB |
Before ![]() (image error) Size: 32 KiB |
Before ![]() (image error) Size: 35 KiB |
Before ![]() (image error) Size: 37 KiB |
Before ![]() (image error) Size: 31 KiB |
Before ![]() (image error) Size: 32 KiB |
Before ![]() (image error) Size: 2.6 MiB |
Before ![]() (image error) Size: 2.8 MiB |
Before ![]() (image error) Size: 539 KiB |
Before ![]() (image error) Size: 585 KiB |
Before ![]() (image error) Size: 236 KiB |