From dd4e776175ba772508596fbca9d17262fe96d81a Mon Sep 17 00:00:00 2001 From: Daniel Bulant Date: Sat, 20 Jun 2026 22:51:47 +0200 Subject: [PATCH] fixup question --- .../__tests__/question-generation.test.ts | 14 ++++---- .../__tests__/question-generator.test.ts | 4 +-- api/src/party/audio-question-generator.ts | 33 ++++++++++--------- web/src/components/device-choice.tsx | 2 +- 4 files changed, 28 insertions(+), 25 deletions(-) diff --git a/api/src/party/__tests__/question-generation.test.ts b/api/src/party/__tests__/question-generation.test.ts index 8554c4c..c732262 100644 --- a/api/src/party/__tests__/question-generation.test.ts +++ b/api/src/party/__tests__/question-generation.test.ts @@ -160,7 +160,7 @@ describe("question generation", () => { questionIndex: 0, question: { ...makeChoiceQuestion( - "Which genre appears most in the party analytics?", + "Which genre is shared by the most party members?", "audio:genre:pop", "genre:pop", ), @@ -175,7 +175,7 @@ describe("question generation", () => { key: "audio:genre:pop", subjectKey: "genre:pop", question: makeChoiceQuestion( - "Which genre appears most in the party analytics?", + "Which genre is shared by the most party members?", "audio:genre:pop", "genre:pop", ), @@ -184,7 +184,7 @@ describe("question generation", () => { key: "audio:artist:abba", subjectKey: "artist:abba", question: makeChoiceQuestion( - "Which artist shows up most often in the shared audio data?", + "Which artist is ranked highest in the shared audio data?", "audio:artist:abba", "artist:abba", ), @@ -195,7 +195,7 @@ describe("question generation", () => { ); expect(question?.text).toBe( - "Which artist shows up most often in the shared audio data?", + "Which artist is ranked highest in the shared audio data?", ); }); @@ -569,7 +569,7 @@ describe("question generation", () => { expect(question?.questionKey).toBe("audio:genre:jazz"); expect(question?.text).toBe( - "Which of these genres appears in the party analytics?", + "Which genre is ranked #3 in the party's shared genres?", ); } finally { randomSpy.mockRestore(); @@ -583,7 +583,7 @@ describe("question generation", () => { ]); const question = { type: "choice" as const, - text: "Which genre appears most in the party analytics?", + text: "Which genre is shared by the most party members?", correct: 0, startTimestamp: 1, endTimestamp: 2, @@ -658,7 +658,7 @@ describe("question generation", () => { ]); const question = { type: "choice" as const, - text: "Which genre appears most in the party analytics?", + text: "Which genre is shared by the most party members?", correct: 0, startTimestamp: 1, endTimestamp: 2, diff --git a/api/src/party/__tests__/question-generator.test.ts b/api/src/party/__tests__/question-generator.test.ts index f45097e..5397375 100644 --- a/api/src/party/__tests__/question-generator.test.ts +++ b/api/src/party/__tests__/question-generator.test.ts @@ -66,7 +66,7 @@ describe("generatePartyQuestion", () => { it("attaches a fallback song to generated questions", async () => { mockResolvedQuestion(audioQuestionGenerator.buildAudioMetadataQuestion, { type: "choice", - text: "Which genre appears most in the party analytics?", + text: "Which genre is shared by the most party members?", correct: 0, startTimestamp: 1, endTimestamp: 2, @@ -119,7 +119,7 @@ describe("generatePartyQuestion", () => { it("prefers metadata questions over social questions when available", async () => { mockResolvedQuestion(audioQuestionGenerator.buildAudioMetadataQuestion, { type: "choice", - text: "Which track appears in the party analytics?", + text: "Which track is ranked #2 in the party analysis?", correct: 0, startTimestamp: 1, endTimestamp: 2, diff --git a/api/src/party/audio-question-generator.ts b/api/src/party/audio-question-generator.ts index e9a322d..b65222b 100644 --- a/api/src/party/audio-question-generator.ts +++ b/api/src/party/audio-question-generator.ts @@ -100,7 +100,9 @@ export async function buildAudioMetadataQuestion( const genreNames = buildOrderedOptions(getMostSharedGenreNames(analytics), 4); if (genreNames) { - for (const genre of genreNames.slice(0, METADATA_ENTITY_POOL_SIZE)) { + for (const [genreIndex, genre] of genreNames + .slice(0, METADATA_ENTITY_POOL_SIZE) + .entries()) { const genreOptions = buildOptionsWithCorrect(genre, genreNames, 4); if (genreOptions) { questions.push({ @@ -109,9 +111,9 @@ export async function buildAudioMetadataQuestion( question: { type: "choice", text: - genre === genreNames[0] - ? "Which genre appears most in the party analytics?" - : "Which of these genres appears in the party analytics?", + genreIndex === 0 + ? "Which genre is shared by the most party members?" + : `Which genre is ranked #${genreIndex + 1} in the party's shared genres?`, options: genreOptions.options, correct: genreOptions.correct, points: 10, @@ -124,10 +126,9 @@ export async function buildAudioMetadataQuestion( const topArtistEntities = getFairQuestionArtists(analytics, members, history); const topArtists = topArtistEntities.map((artist) => artist.name); - for (const topArtist of topArtistEntities.slice( - 0, - METADATA_ENTITY_POOL_SIZE, - )) { + for (const [artistIndex, topArtist] of topArtistEntities + .slice(0, METADATA_ENTITY_POOL_SIZE) + .entries()) { const artistOptions = buildOptionsWithCorrect( topArtist.name, topArtists, @@ -141,9 +142,9 @@ export async function buildAudioMetadataQuestion( question: { type: "choice", text: - topArtist === topArtistEntities[0] - ? "Which artist shows up most often in the shared audio data?" - : "Which artist shows up in the shared audio data?", + artistIndex === 0 + ? "Which artist is ranked highest in the shared audio data?" + : `Which artist is ranked #${artistIndex + 1} in the shared audio data?`, options: artistOptions.options, correct: artistOptions.correct, points: 10, @@ -153,7 +154,9 @@ export async function buildAudioMetadataQuestion( } } - for (const topTrack of topTracks.slice(0, METADATA_ENTITY_POOL_SIZE)) { + for (const [trackIndex, topTrack] of topTracks + .slice(0, METADATA_ENTITY_POOL_SIZE) + .entries()) { const topTrackName = topTrack?.name; const trackOptions = topTrackName ? buildOptionsWithCorrect(topTrackName, topTrackNames, 4) @@ -166,10 +169,10 @@ export async function buildAudioMetadataQuestion( question: { type: "choice", text: - topTrack === topTracks[0] && + trackIndex === 0 && getTrackFairness(topTrack, members, history).memberCount > 1 - ? "Which track looks most shared across the party?" - : "Which track appears in the party analytics?", + ? "Which track is ranked highest across the party?" + : `Which track is ranked #${trackIndex + 1} in the party analysis?`, options: trackOptions.options, correct: trackOptions.correct, points: 10, diff --git a/web/src/components/device-choice.tsx b/web/src/components/device-choice.tsx index 5a5aa4f..8a23f22 100644 --- a/web/src/components/device-choice.tsx +++ b/web/src/components/device-choice.tsx @@ -26,7 +26,7 @@ export function DeviceChoice() { enabled: Boolean(user && !party && !dismissed), }); - if (!user || party || dismissed || isLoading) return null; + if (!user || dismissed || isLoading) return null; const devices = data?.data?.devices ?? []; if (devices.length > 0) return null;