feat: publish approved RF4 media catalog
CI / backend-and-migrations (push) Canceled after 0s
CI / astro-build (push) Canceled after 0s
CI / dependency-audit (push) Canceled after 0s
CI / compose-e2e (push) Canceled after 0s

This commit is contained in:
ik
2026-09-14 22:20:46 +07:00
parent 6146ea9eb0
commit b47a6cc366
25 changed files with 2487 additions and 893 deletions
+23
View File
@@ -0,0 +1,23 @@
import type { MediaAsset } from "./api";
const tokens = (value: string) => value
.toLocaleLowerCase("ru")
.replaceAll("ё", "е")
.replace(/^(оз\.|р\.)\s*/, "")
.replace(/[^a-zа-я0-9]+/giu, " ")
.trim()
.split(/\s+/)
.filter(Boolean);
export const findMediaByLabel = (assets: MediaAsset[], label: string): MediaAsset | undefined => {
const wanted = tokens(label);
const exact = assets.filter((asset) => tokens(asset.label ?? "").join(" ") === wanted.join(" "));
if (exact.length === 1) return exact[0];
const wantedSet = new Set(wanted);
const candidates = assets.filter((asset) => {
const available = new Set(tokens(asset.label ?? ""));
return wanted.every((token) => available.has(token)) || [...available].every((token) => wantedSet.has(token));
});
return candidates.length === 1 ? candidates[0] : undefined;
};