From ca5fedd65c734c5aceacd4374dd200131f6c8d4e Mon Sep 17 00:00:00 2001 From: Shaheed Azaad Date: Mon, 10 Nov 2025 23:56:55 +0100 Subject: [PATCH] updated demo based on musicians feedback --- src/routes/admin/+page.svelte | 2 +- src/routes/admin/audio/+page.svelte | 2 +- src/routes/api/export/timeseries/+server.js | 42 ++++++++++++++++----- 3 files changed, 35 insertions(+), 11 deletions(-) diff --git a/src/routes/admin/+page.svelte b/src/routes/admin/+page.svelte index 0d4cb8d..c7df02f 100644 --- a/src/routes/admin/+page.svelte +++ b/src/routes/admin/+page.svelte @@ -237,7 +237,7 @@ type="text" name="tags" value={invite.tags?.join(', ') ?? ''} - placeholder="beta, cohort-a" + placeholder="tag1, tag2, tag3" class="w-full rounded-md border-gray-300 px-2 py-1 text-xs focus:border-indigo-500 focus:ring-indigo-500" title="Comma-separated list. Leave blank to remove all tags" /> diff --git a/src/routes/admin/audio/+page.svelte b/src/routes/admin/audio/+page.svelte index c52895e..f461851 100644 --- a/src/routes/admin/audio/+page.svelte +++ b/src/routes/admin/audio/+page.svelte @@ -453,7 +453,7 @@ type="text" name="tags" value={audio.tags?.join(', ') ?? ''} - placeholder="rock, jazz, intro" + placeholder="tag1, tag2, tag3" class="w-full rounded-md border-gray-300 px-2 py-1 text-xs focus:border-indigo-500 focus:ring-indigo-500" title="Comma-separated list. Leave blank to remove all tags" /> diff --git a/src/routes/api/export/timeseries/+server.js b/src/routes/api/export/timeseries/+server.js index 997a3a6..fea717b 100644 --- a/src/routes/api/export/timeseries/+server.js +++ b/src/routes/api/export/timeseries/+server.js @@ -28,7 +28,14 @@ export async function GET() { // Get overall ratings const overallRatings = await db .select({ - overallRating, + overallRating: { + id: overallRating.id, + participantId: overallRating.participantId, + audioFileId: overallRating.audioFileId, + value: overallRating.value, + temporalValue: overallRating.temporalValue, + createdAt: overallRating.createdAt + }, participant, audioFile, inviteLink @@ -96,14 +103,23 @@ export async function GET() { // Ensure the participant exists in timeseriesData if (timeseriesData[audioId] && timeseriesData[audioId].participants[participantId]) { - timeseriesData[audioId].participants[participantId].overallRating = entry.overallRating.value; + timeseriesData[audioId].participants[participantId].overallResponses = { + temporal: entry.overallRating.temporalValue, + overall: entry.overallRating.value, + createdAt: entry.overallRating.createdAt + }; + timeseriesData[audioId].participants[participantId].isCompleted = true; } else if (timeseriesData[audioId]) { // Participant has overall rating but no timeseries data yet timeseriesData[audioId].participants[participantId] = { name: participantName, ratings: [], - isCompleted: false, - overallRating: entry.overallRating.value + isCompleted: true, + overallResponses: { + temporal: entry.overallRating.temporalValue, + overall: entry.overallRating.value, + createdAt: entry.overallRating.createdAt + } }; } else { // Neither audio nor participant exists in timeseriesData yet @@ -113,8 +129,12 @@ export async function GET() { [participantId]: { name: participantName, ratings: [], - isCompleted: false, - overallRating: entry.overallRating.value + isCompleted: true, + overallResponses: { + temporal: entry.overallRating.temporalValue, + overall: entry.overallRating.value, + createdAt: entry.overallRating.createdAt + } } } }; @@ -132,6 +152,7 @@ export async function GET() { 'Status', 'Data Points Count', 'Duration Covered (seconds)', + 'Temporal Rating (0-100)', 'Overall Rating (0-100)', 'Timeseries Data (timestamp:value pairs)', 'Last Updated' @@ -155,8 +176,10 @@ export async function GET() { Math.max(...participantData.ratings.map(r => r.timestamp)) : 0; const durationCovered = maxTimestamp - minTimestamp; - const lastUpdated = participantData.ratings.length > 0 ? + const overallResponses = participantData.overallResponses; + const lastTimeseriesUpdate = participantData.ratings.length > 0 ? new Date(Math.max(...participantData.ratings.map(r => new Date(r.createdAt).getTime()))) : null; + const lastUpdated = lastTimeseriesUpdate ?? (overallResponses ? new Date(overallResponses.createdAt) : null); // Use the stored timeseries data from the rating record const timeseriesData = participantData.ratings.find(r => r.isCompleted && r.timeseriesData)?.timeseriesData || @@ -168,7 +191,8 @@ export async function GET() { participantData.isCompleted ? 'Completed' : 'In Progress', participantData.ratings.length, durationCovered.toFixed(2), - participantData.overallRating !== undefined ? participantData.overallRating : '-', + overallResponses?.temporal ?? '-', + overallResponses?.overall ?? '-', timeseriesData, lastUpdated ? lastUpdated.toLocaleString() : '-' ]); @@ -208,4 +232,4 @@ export async function GET() { } }); } -} \ No newline at end of file +}