more fuzzy matching for migrations

Co-authored-by: Jip Frijlink <JipFr@users.noreply.github.com>
This commit is contained in:
mrjvs 2023-02-18 14:03:48 +01:00
parent 4d4626806d
commit ad518a6508

View File

@ -1,6 +1,7 @@
import { DetailedMeta, getMetaFromId } from "@/backend/metadata/getmeta"; import { DetailedMeta, getMetaFromId } from "@/backend/metadata/getmeta";
import { searchForMedia } from "@/backend/metadata/search"; import { searchForMedia } from "@/backend/metadata/search";
import { MWMediaMeta, MWMediaType } from "@/backend/metadata/types"; import { MWMediaMeta, MWMediaType } from "@/backend/metadata/types";
import { compareTitle } from "@/utils/titleMatch";
import { WatchedStoreData, WatchedStoreItem } from "../types"; import { WatchedStoreData, WatchedStoreItem } from "../types";
interface OldMediaBase { interface OldMediaBase {
@ -49,10 +50,10 @@ async function getMetas(
type: item.mediaType, type: item.mediaType,
}); });
const relevantItem = data.find((res) => const relevantItem = data.find((res) =>
yearsAreClose(Number(res.year), year) yearsAreClose(Number(res.year), year) && compareTitle(res.title, item.title)
); );
if (!relevantItem) { if (!relevantItem) {
console.error("No item"); console.error("No item found for migration: " + item.title);
return; return;
} }
return { return {