refine speaking practice filter to inspect audio rows

Filter speaking practice options using returned AUDIO question rows instead of total_count so unrelated practices are excluded reliably.

Made-with: Cursor
This commit is contained in:
Yared Yemane 2026-04-07 04:28:22 -07:00
parent e7e64ad2ed
commit c648c6668b

View File

@ -324,12 +324,15 @@ export function SpeakingPage() {
all.map(async (practice) => { all.map(async (practice) => {
try { try {
const res = await getPracticeQuestionsByPractice(practice.id, { const res = await getPracticeQuestionsByPractice(practice.id, {
limit: 1, limit: 20,
offset: 0, offset: 0,
question_type: "AUDIO", question_type: "AUDIO",
}) })
const total = res.data?.data?.total_count ?? 0 const questions = res.data?.data?.questions ?? []
return total > 0 ? practice : null const hasAudioQuestion = questions.some(
(question) => (question.question_type ?? "").toUpperCase() === "AUDIO",
)
return hasAudioQuestion ? practice : null
} catch { } catch {
return null return null
} }