Raw search results from API
Original search title
Search configuration
OptionalkenmeiManga: KenmeiMangaOptional Kenmei manga for custom rule evaluation
Ranked manga results
export function processSearchResults(
results: AniListManga[],
title: string,
searchConfig: SearchServiceConfig,
kenmeiManga?: KenmeiManga,
): AniListManga[] {
console.debug(
`[MangaSearchService] 🔍 Found ${results.length} raw results for "${title}" before filtering/ranking`,
);
let isExactMatchMode = searchConfig.exactMatchingOnly;
if ((searchConfig.bypassCache && results.length > 0) || results.length <= 3) {
isExactMatchMode = false;
}
const rankedResults = rankMangaResults(
results,
title,
isExactMatchMode,
searchConfig.bypassCache,
kenmeiManga,
);
console.info(
`[MangaSearchService] 🔍 Search complete for "${title}": Found ${results.length} results, ranked to ${rankedResults.length} relevant matches`,
);
// Cache results if not bypassing cache
if (searchConfig.bypassCache) {
console.debug(
`[MangaSearchService] 🔍 MANUAL SEARCH: Skipping cache save for "${title}"`,
);
} else {
const cacheKey = generateCacheKey(title);
mangaCache[cacheKey] = {
manga: rankedResults,
timestamp: Date.now(),
};
saveCache();
}
return rankedResults;
}
Process and rank search results, optionally caching them.
Applies filtering, ranking, and custom matching rules.