From 3bfe1e8fdb4b167ca90f2183c7c080903ebf1b5d Mon Sep 17 00:00:00 2001 From: DebaucheryLibrarian Date: Mon, 20 Dec 2021 03:29:14 +0100 Subject: [PATCH] Storing scenes before fetching movies. --- src/app.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/app.js b/src/app.js index 3d98d188..0cfaf2f4 100644 --- a/src/app.js +++ b/src/app.js @@ -36,7 +36,7 @@ function logActive() { async function snapshotMemory() { const profile = await inspector.heap.takeSnapshot(); - const filepath = `${dayjs().format('traxxx_snapshot_YYYY-MM-DD_HH-mm-ss')}.heapprofile`; + const filepath = `traxxx_snapshot_${dayjs().format('YYYY-MM-DD_HH-mm-ss')}.heapprofile`; logger.info(`Start heap snapshots, memory usage: ${process.memoryUsage.rss() / 1000000} MB`); @@ -48,7 +48,7 @@ async function snapshotMemory() { async function stopMemorySample(snapshotTriggers) { const profile = await inspector.heap.stopSampling(); - const filepath = `${dayjs().format('traxxx_sample_YYYY-MM-DD_HH-mm-ss')}.heapprofile`; + const filepath = `traxxx_sample_${dayjs().format('YYYY-MM-DD_HH-mm-ss')}.heapprofile`; const usage = process.memoryUsage.rss() / 1000000; await inspector.heap.disable(); @@ -168,6 +168,8 @@ async function init() { ? await fetchScenes([...(sceneUrls), ...(updateBaseScenes || []), ...(actorBaseScenes || [])]) : [...(updateBaseScenes || []), ...(actorBaseScenes || [])]; + const storedScenes = argv.save ? await storeScenes(deepScenes) : []; + const sceneMovies = deepScenes ? deepScenes.filter((scene) => scene.movie).map((scene) => ({ ...scene.movie, entity: scene.entity })) : []; const deepMovies = argv.sceneMovies || argv.movie ? await fetchMovies([...(argv.movie || []), ...(sceneMovies || [])]) : sceneMovies; @@ -181,9 +183,9 @@ async function init() { if (argv.save) { const storedMovies = await storeMovies(deepMovies); - const storedScenes = await storeScenes([...(deepScenes || []), ...(deepMovieScenes || [])]); + const storedMovieScenes = await storeScenes(deepMovieScenes); - await associateMovieScenes(storedMovies, storedScenes); + await associateMovieScenes(storedMovies, [...storedScenes, ...storedMovieScenes]); } } catch (error) { logger.error(error);