mirror of
https://github.com/alexankitty/Myrient-Search-Engine.git
synced 2026-01-15 16:33:15 -03:00
adjust resync so it doesn't force a repull of the metadata from igdb if it's current
This commit is contained in:
@@ -115,25 +115,37 @@ export default class MetadataManager {
|
||||
}
|
||||
|
||||
async matchAllMetadata(fuzzy = false) {
|
||||
let games = await File.findAll({
|
||||
where: {
|
||||
nongame: false,
|
||||
detailsId: null,
|
||||
},
|
||||
attributes: ["id", "filename", "category"],
|
||||
order: ["id", "filename"],
|
||||
include: { model: Metadata, as: "details" },
|
||||
});
|
||||
let games = [];
|
||||
if (process.env.FORCE_METADATA_RESYNC == "1") {
|
||||
games = await File.findAll({
|
||||
where: {
|
||||
nongame: false,
|
||||
},
|
||||
attributes: ["id", "filename", "category"],
|
||||
order: ["id", "filename"],
|
||||
include: { model: Metadata, as: "details" },
|
||||
});
|
||||
} else {
|
||||
games = await File.findAll({
|
||||
where: {
|
||||
nongame: false,
|
||||
detailsId: null,
|
||||
},
|
||||
attributes: ["id", "filename", "category"],
|
||||
order: ["id", "filename"],
|
||||
include: { model: Metadata, as: "details" },
|
||||
});
|
||||
}
|
||||
|
||||
let count = games.length;
|
||||
let timer = new Timer();
|
||||
let found = 0;
|
||||
console.log(`Matching ${count} games to metadata.`);
|
||||
for (let x = 0; x < count; x++) {
|
||||
singleLineStatus(
|
||||
`Matching metadata: ${x} / ${count} ${(
|
||||
((x) / count) *
|
||||
100
|
||||
).toFixed(2)}% (${timer.elapsed()}) Total Matches: ${found}`
|
||||
`Matching metadata: ${x} / ${count} ${((x / count) * 100).toFixed(
|
||||
2
|
||||
)}% (${timer.elapsed()}) Total Matches: ${found}`
|
||||
);
|
||||
let game = games[x];
|
||||
let metadata = await Metadata.searchByText(
|
||||
|
||||
@@ -115,8 +115,12 @@ async function getFilesJob() {
|
||||
|
||||
async function updateMetadata() {
|
||||
if (updatingFiles) return;
|
||||
if ((await Metadata.count()) < (await metadataManager.getIGDBGamesCount()) || process.env.FORCE_METADATA_RESYNC == "1") {
|
||||
let updateMatches = process.env.FORCE_METADATA_RESYNC == "1" ? true : false
|
||||
if ((await Metadata.count()) < (await metadataManager.getIGDBGamesCount())) {
|
||||
await metadataManager.syncAllMetadata();
|
||||
updateMatches = true;
|
||||
}
|
||||
if(updateMatches){
|
||||
if (await Metadata.count()) {
|
||||
await metadataManager.matchAllMetadata();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user