mirror of
https://github.com/alexankitty/Myrient-Search-Engine.git
synced 2026-01-15 08:23:18 -03:00
make fuzzy metadata search happen after all other database operations have settled.
This commit is contained in:
@@ -66,7 +66,7 @@ export default class MetadataSearch {
|
||||
this.platformMap = JSON.parse(readFileSync(mapFilePath, "utf8"));
|
||||
if (this.accessToken) {
|
||||
this.authorized = true;
|
||||
this.syncAllMetadata();
|
||||
this.matchAllMetadata();
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -110,7 +110,7 @@ export default class MetadataSearch {
|
||||
}
|
||||
}
|
||||
|
||||
async matchAllMetadata() {
|
||||
async matchAllMetadata(fuzzy = false) {
|
||||
let games = await File.findAndCountAll({
|
||||
where: {
|
||||
nongame: false,
|
||||
@@ -154,14 +154,15 @@ export default class MetadataSearch {
|
||||
await game.save();
|
||||
await md.save();
|
||||
found++;
|
||||
} else {
|
||||
} else if (fuzzy) {
|
||||
//this is much slower and should only be used if the faster full text search can't find it.
|
||||
let metadata = Metadata.fuzzySearchByText(
|
||||
let metadata = await Metadata.fuzzySearchByText(
|
||||
this.normalizeName(game.filename),
|
||||
0.6,
|
||||
game.category
|
||||
);
|
||||
if (metadata) {
|
||||
if (metadata.length) {
|
||||
let md = await Metadata.findByPk(metadata[0].id);
|
||||
await game.setDetails(md);
|
||||
await md.addFile(game);
|
||||
await game.save();
|
||||
|
||||
@@ -114,7 +114,7 @@ export default function (sequelize) {
|
||||
}
|
||||
const query = `
|
||||
SELECT id FROM "Metadata"
|
||||
WHERE SIMILARITY(title, $1) > $2 OR WHERE SIMILARITY(alternatetitles, $1) > $2
|
||||
WHERE SIMILARITY(title, $1) > $2 OR SIMILARITY(alternatetitles, $1) > $2
|
||||
${platformClause}
|
||||
ORDER BY length(title) ${limitClause}
|
||||
`;
|
||||
|
||||
Reference in New Issue
Block a user