random selection of project proposals
Deploy Vercel / deploy-preprod (push) Failing after 1m18s
Deploy Vercel / deploy-production (push) Has been skipped

This commit is contained in:
2026-07-08 09:31:35 +02:00
parent aadb43efb4
commit 5f41471108
2 changed files with 20 additions and 10 deletions
+13
View File
@@ -41,4 +41,17 @@ export function getAllProjects(locale: string): Project[] {
.map((slug) => getProjectBySlug(slug, locale))
.filter((project): project is Project => project !== null)
.sort((a, b) => a.priority - b.priority);
}
export function getRandomOtherProjects(locale: string, excludeSlug: string, count: number): Project[] {
const candidates = getAllProjects(locale).filter(
(project) => project.slug !== excludeSlug && project.ready
);
for (let i = candidates.length - 1; i > 0; i--) {
const j = Math.floor(Math.random() * (i + 1));
[candidates[i], candidates[j]] = [candidates[j], candidates[i]];
}
return candidates.slice(0, count);
}