mirror of
https://github.com/alexankitty/Myrient-Search-Engine.git
synced 2026-01-15 16:33:15 -03:00
add tasks to implement metadata and kws if they're empty (but block them by the main file update)
This commit is contained in:
43
server.js
43
server.js
@@ -40,6 +40,7 @@ let metadataMatchCount = 0;
|
|||||||
let indexPage = "pages/index";
|
let indexPage = "pages/index";
|
||||||
let flags = new Flag();
|
let flags = new Flag();
|
||||||
let consoleIcons = new ConsoleIcons(emulatorsData);
|
let consoleIcons = new ConsoleIcons(emulatorsData);
|
||||||
|
let updatingFiles = false;
|
||||||
import { Op } from "sequelize";
|
import { Op } from "sequelize";
|
||||||
|
|
||||||
// Initialize databases
|
// Initialize databases
|
||||||
@@ -80,6 +81,7 @@ let search = new Searcher(searchFields);
|
|||||||
let metadataManager = new MetadataManager();
|
let metadataManager = new MetadataManager();
|
||||||
|
|
||||||
async function getFilesJob() {
|
async function getFilesJob() {
|
||||||
|
updatingFiles = true;
|
||||||
console.log("Updating the file list.");
|
console.log("Updating the file list.");
|
||||||
let oldFileCount = fileCount || 0;
|
let oldFileCount = fileCount || 0;
|
||||||
fileCount = await getAllFiles(categoryList);
|
fileCount = await getAllFiles(categoryList);
|
||||||
@@ -89,16 +91,18 @@ async function getFilesJob() {
|
|||||||
}
|
}
|
||||||
crawlTime = Date.now();
|
crawlTime = Date.now();
|
||||||
console.log(`Finished updating file list. ${fileCount} found.`);
|
console.log(`Finished updating file list. ${fileCount} found.`);
|
||||||
if ((await Metadata.count()) < (await metadataManager.getIGDBGamesCount())) {
|
|
||||||
await metadataManager.syncAllMetadata();
|
|
||||||
metadataMatchCount = await File.count({
|
|
||||||
where: { detailsId: { [Op.ne]: null } },
|
|
||||||
});
|
|
||||||
}
|
|
||||||
if (fileCount > oldFileCount) {
|
if (fileCount > oldFileCount) {
|
||||||
await metadataManager.matchAllMetadata();
|
if (
|
||||||
|
(await Metadata.count()) < (await metadataManager.getIGDBGamesCount())
|
||||||
|
) {
|
||||||
|
await metadataManager.syncAllMetadata();
|
||||||
|
await metadataManager.matchAllMetadata();
|
||||||
|
metadataMatchCount = await File.count({
|
||||||
|
where: { detailsId: { [Op.ne]: null } },
|
||||||
|
});
|
||||||
|
}
|
||||||
|
await optimizeDatabaseKws();
|
||||||
}
|
}
|
||||||
await optimizeDatabaseKws();
|
|
||||||
//this is less important and needs to run last.
|
//this is less important and needs to run last.
|
||||||
if (fileCount > oldFileCount) {
|
if (fileCount > oldFileCount) {
|
||||||
metadataManager.matchAllMetadata(true);
|
metadataManager.matchAllMetadata(true);
|
||||||
@@ -106,6 +110,25 @@ async function getFilesJob() {
|
|||||||
metadataMatchCount = await File.count({
|
metadataMatchCount = await File.count({
|
||||||
where: { detailsId: { [Op.ne]: null } },
|
where: { detailsId: { [Op.ne]: null } },
|
||||||
});
|
});
|
||||||
|
updatingFiles = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
async function updateMetadata() {
|
||||||
|
if (updatingFiles) return;
|
||||||
|
if ((await Metadata.count()) < (await metadataManager.getIGDBGamesCount())) {
|
||||||
|
await metadataManager.syncAllMetadata();
|
||||||
|
await metadataManager.matchAllMetadata();
|
||||||
|
metadataMatchCount = await File.count({
|
||||||
|
where: { detailsId: { [Op.ne]: null } },
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function updateKws() {
|
||||||
|
if (updatingFiles) return;
|
||||||
|
if (!await File.count({ where: { filenamekws: { [Op.ne]: null } } })) {
|
||||||
|
await optimizeDatabaseKws();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function buildOptions(page, options) {
|
function buildOptions(page, options) {
|
||||||
@@ -588,3 +611,7 @@ if (
|
|||||||
}
|
}
|
||||||
|
|
||||||
cron.schedule("0 30 2 * * *", getFilesJob);
|
cron.schedule("0 30 2 * * *", getFilesJob);
|
||||||
|
|
||||||
|
//run these tasks after to add new functions
|
||||||
|
updateMetadata()
|
||||||
|
updateKws()
|
||||||
Reference in New Issue
Block a user