• Processes a batch of Kenmei manga entries, finding best AniList matches for each.

    Groups AniList candidates by normalized title prefix (first 10 chars) for efficient lookup. Logs progress and completion statistics.

    Parameters

    • kenmeiMangaList: KenmeiManga[]

      Kenmei entries to match.

    • anilistMangaMap: Map<string, AniListManga[]>

      Map of search keys to AniList candidates.

    • config: Partial<MatchEngineConfig> = {}

      Partial config to override defaults.

    Returns Promise<MangaMatchResult[]>

    Promise resolving to array of match results (one per Kenmei entry).

    export async function processBatchMatches(
    kenmeiMangaList: KenmeiManga[],
    anilistMangaMap: Map<string, AniListManga[]>,
    config: Partial<MatchEngineConfig> = {},
    ): Promise<MangaMatchResult[]> {
    console.info(
    `[MatchEngine] 🔍 Processing batch matches for ${kenmeiMangaList.length} manga entries`,
    );
    console.debug(
    `[MatchEngine] 🔍 AniList manga map contains ${anilistMangaMap.size} search keys`,
    );

    const results = kenmeiMangaList.map((kenmeiManga) => {
    const searchKey = normalizeString(kenmeiManga.title).slice(0, 10);
    const potentialMatches = anilistMangaMap.get(searchKey) || [];
    return findBestMatches(kenmeiManga, potentialMatches, config);
    });

    const matchedCount = results.filter(
    (r) => r.anilistMatches && r.anilistMatches.length > 0,
    ).length;
    console.info(
    `[MatchEngine] ✅ Batch processing complete: ${matchedCount}/${kenmeiMangaList.length} with matches`,
    );

    return results;
    }