added randomisation
This commit is contained in:
@@ -4,6 +4,7 @@ import { inviteLink, participant, audioFile, rating, overallRating } from '$lib/
|
||||
import { eq, isNull, and, inArray } from 'drizzle-orm';
|
||||
import { parseStoredTags, matchesInviteTags } from '$lib/server/tag-utils.js';
|
||||
import { env } from '$env/dynamic/private';
|
||||
import shuffle from 'knuth-shuffle-seeded';
|
||||
|
||||
export async function load({ url, cookies }) {
|
||||
const token = url.searchParams.get('token');
|
||||
@@ -81,7 +82,7 @@ export async function load({ url, cookies }) {
|
||||
.from(audioFile)
|
||||
.where(isNull(audioFile.deletedAt)); // Only show active audio files
|
||||
|
||||
const filteredAudio = audioRows
|
||||
const baseAudioList = audioRows
|
||||
.map((audio) => ({
|
||||
data: {
|
||||
id: audio.id,
|
||||
@@ -96,6 +97,11 @@ export async function load({ url, cookies }) {
|
||||
.filter(({ tags }) => matchesInviteTags(tags, inviteTags))
|
||||
.map(({ data }) => data);
|
||||
|
||||
const shuffleSeed = participantId || token;
|
||||
const filteredAudio = baseAudioList.length > 0
|
||||
? shuffle([...baseAudioList], shuffleSeed)
|
||||
: baseAudioList;
|
||||
|
||||
const allowedAudioIds = filteredAudio.map((file) => file.id);
|
||||
|
||||
const displayContinuousRating = env.DISPLAY_CONT_RATING !== 'false';
|
||||
|
||||
Reference in New Issue
Block a user