InternalThe match to check.
Selected status filters (matched, manual, pending, skipped).
Minimum confidence threshold (null or 0-100).
Include entries without matches.
Export only unmatched entries (takes precedence).
True if the match passes all applied filters.
export function matchPassesFilter(
match: MangaMatchResult,
statusFilters: Set<string> | string[],
confidenceThreshold: number | null,
includeUnmatched: boolean,
unmatchedOnly: boolean,
): boolean {
const statusFilterSet =
statusFilters instanceof Set ? statusFilters : new Set(statusFilters);
// Check status filter
if (!statusFilterSet.has(match.status)) {
return false;
}
// Check confidence threshold
if (confidenceThreshold !== null && confidenceThreshold > 0) {
const highestConfidence =
match.anilistMatches && match.anilistMatches.length > 0
? Math.max(...match.anilistMatches.map((m) => m.confidence ?? 0))
: 0;
if (highestConfidence < confidenceThreshold) {
return false;
}
}
// Check unmatchedOnly filter (takes precedence over includeUnmatched)
if (unmatchedOnly) {
const isUnmatched =
!match.selectedMatch &&
(!match.anilistMatches || match.anilistMatches.length === 0);
return isUnmatched;
}
// Check includeUnmatched filter
if (!includeUnmatched) {
const isMatched = !!(
match.selectedMatch ||
(match.anilistMatches && match.anilistMatches.length > 0)
);
return isMatched;
}
return true;
}
Checks if a match passes all filter criteria; used by UI preview and export to keep results in sync.