Fixed pagination and scene poster overflowing page on small screens. Fixed back reload interfering with tag page hashes.
This commit is contained in:
@@ -1,28 +1,28 @@
|
||||
import { indexApi, utilsApi } from '../manticore.js';
|
||||
import rawMovies from './movies.json' with { type: 'json' };
|
||||
import rawvideos from './movies.json' with { type: 'json' };
|
||||
|
||||
async function fetchMovies() {
|
||||
const movies = rawMovies
|
||||
.filter((movie) => movie.cast.length > 0
|
||||
&& movie.genres.length > 0
|
||||
&& movie.cast.every((actor) => actor.charCodeAt(0) >= 65)) // throw out movies with non-alphanumerical actor names
|
||||
.map((movie, index) => ({ id: index + 1, ...movie }));
|
||||
async function fetchvideos() {
|
||||
const videos = rawvideos
|
||||
.filter((video) => video.cast.length > 0
|
||||
&& video.genres.length > 0
|
||||
&& video.cast.every((actor) => actor.charCodeAt(0) >= 65)) // throw out videos with non-alphanumerical actor names
|
||||
.map((video, index) => ({ id: index + 1, ...video }));
|
||||
|
||||
const actors = Array.from(new Set(movies.flatMap((movie) => movie.cast))).sort();
|
||||
const genres = Array.from(new Set(movies.flatMap((movie) => movie.genres)));
|
||||
const actors = Array.from(new Set(videos.flatMap((video) => video.cast))).sort();
|
||||
const genres = Array.from(new Set(videos.flatMap((video) => video.genres)));
|
||||
|
||||
return {
|
||||
movies,
|
||||
videos,
|
||||
actors,
|
||||
genres,
|
||||
};
|
||||
}
|
||||
|
||||
async function init() {
|
||||
await utilsApi.sql('drop table if exists movies');
|
||||
await utilsApi.sql('drop table if exists movies_liked');
|
||||
await utilsApi.sql('drop table if exists videos');
|
||||
await utilsApi.sql('drop table if exists videos_liked');
|
||||
|
||||
await utilsApi.sql(`create table movies (
|
||||
await utilsApi.sql(`create table videos (
|
||||
id int,
|
||||
title text,
|
||||
actor_ids multi,
|
||||
@@ -31,37 +31,37 @@ async function init() {
|
||||
genres text
|
||||
)`);
|
||||
|
||||
await utilsApi.sql(`create table movies_liked (
|
||||
await utilsApi.sql(`create table videos_liked (
|
||||
id int,
|
||||
user_id int,
|
||||
movie_id int
|
||||
video_id int
|
||||
)`);
|
||||
|
||||
const { movies, actors, genres } = await fetchMovies();
|
||||
const { videos, actors, genres } = await fetchvideos();
|
||||
|
||||
const likedMovieIds = Array.from(new Set(Array.from({ length: 10.000 }, () => movies[Math.round(Math.random() * movies.length)].id)));
|
||||
const likedvideoIds = Array.from(new Set(Array.from({ length: 10.000 }, () => videos[Math.round(Math.random() * videos.length)].id)));
|
||||
|
||||
const docs = movies
|
||||
.map((movie) => ({
|
||||
const docs = videos
|
||||
.map((video) => ({
|
||||
replace: {
|
||||
index: 'movies',
|
||||
id: movie.id,
|
||||
index: 'videos',
|
||||
id: video.id,
|
||||
doc: {
|
||||
title: movie.title,
|
||||
actor_ids: movie.cast.map((actor) => actors.indexOf(actor)),
|
||||
actors: movie.cast.join(','),
|
||||
genre_ids: movie.genres.map((genre) => genres.indexOf(genre)),
|
||||
genres: movie.genres.join(','),
|
||||
title: video.title,
|
||||
actor_ids: video.cast.map((actor) => actors.indexOf(actor)),
|
||||
actors: video.cast.join(','),
|
||||
genre_ids: video.genres.map((genre) => genres.indexOf(genre)),
|
||||
genres: video.genres.join(','),
|
||||
},
|
||||
},
|
||||
}))
|
||||
.concat(likedMovieIds.map((movieId, index) => ({
|
||||
.concat(likedvideoIds.map((videoId, index) => ({
|
||||
replace: {
|
||||
index: 'movies_liked',
|
||||
index: 'videos_liked',
|
||||
id: index + 1,
|
||||
doc: {
|
||||
user_id: Math.floor(Math.random() * 51),
|
||||
movie_id: movieId,
|
||||
video_id: videoId,
|
||||
},
|
||||
},
|
||||
})));
|
||||
@@ -71,7 +71,7 @@ async function init() {
|
||||
console.log('data', data);
|
||||
|
||||
const result = await utilsApi.sql(`
|
||||
select * from movies_liked
|
||||
select * from videos_liked
|
||||
limit 10
|
||||
`);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user