Naslovnica: razmik po skupini izvajalca (Rier = Kastelruther Spatzen), Beliebt brez podvojitev iz bazena

This commit is contained in:
folx bot
2026-08-29 20:34:27 +02:00
parent 12694d6db8
commit 85e7a1e7c7
4 changed files with 48 additions and 15 deletions
+12 -9
View File
@@ -1,5 +1,5 @@
import { useQuery } from "@tanstack/react-query";
import { artistKey } from "@/lib/artists";
import { artistGroup } from "@/lib/artists";
import { Link } from "wouter";
import { type Article } from "@shared/schema";
import { format } from "date-fns";
@@ -190,13 +190,13 @@ function razmakniPoIzvajalcu(list: Article[], razmik = 5, seed: string[] = []):
const recent: string[] = seed.filter(Boolean).slice(-(razmik - 1));
while (rest.length) {
let idx = rest.findIndex((a) => {
const k = artistKey(a?.title || "");
const k = artistGroup(a?.title || "");
return !k || !recent.includes(k);
});
if (idx < 0) idx = 0;
const a = rest.splice(idx, 1)[0];
out.push(a);
recent.push(artistKey(a?.title || ""));
recent.push(artistGroup(a?.title || ""));
if (recent.length >= razmik) recent.shift();
}
return out;
@@ -261,11 +261,14 @@ function MobileMosaic({ latest, popular, focalPoints }: { latest: Article[]; pop
if (l.length === 0) return null;
const usedIds = new Set(pool.map((a) => a.id));
const seenNow = l.map((a) => artistKey(a?.title || "")).filter(Boolean);
const poolGroups = new Set(pool.map((a) => artistGroup(a?.title || "")).filter(Boolean));
const kandidati = (popular || []).filter((a) => !usedIds.has(a.id));
const brezPodvojitve = kandidati.filter((a) => {
const g = artistGroup(a?.title || "");
return !g || !poolGroups.has(g);
});
const p = razmakniPoIzvajalcu(
(popular || []).filter((a) => !usedIds.has(a.id)),
5,
seenNow,
brezPodvojitve.length >= 3 ? brezPodvojitve : kandidati,
).slice(0, 3);
const nextStart = ((displayPage + 1) % totalPages) * pageSize;
@@ -806,13 +809,13 @@ export default function Home() {
const recent: string[] = [];
while (rest.length) {
let idx = rest.findIndex((a) => {
const k = artistKey(a.title || "");
const k = artistGroup(a.title || "");
return !k || !recent.includes(k);
});
if (idx < 0) idx = 0;
const a = rest.splice(idx, 1)[0];
out.push(a);
recent.push(artistKey(a.title || ""));
recent.push(artistGroup(a.title || ""));
if (recent.length >= RAZMIK) recent.shift();
}
return out;