Skip to content

Commit 77e961b

Browse files
committed
Fixing parameterized hearing page to use new transcription format, providing example transcription
1 parent f4f97ec commit 77e961b

File tree

1 file changed

+21
-16
lines changed

1 file changed

+21
-16
lines changed

pages/hearing/[...hearingId].tsx renamed to pages/hearing/[hearingId].tsx

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -122,45 +122,50 @@ function formatTime(ms: number) {
122122

123123
export const getServerSideProps: GetServerSideProps = async ctx => {
124124
const locale = ctx.locale ?? ctx.defaultLocale ?? "en"
125-
const query = Query.safeParse(ctx.query)
125+
const query = Query.safeParse(ctx.params)
126126
if (!query.success) return { notFound: true }
127127
const { hearingId } = query.data
128128

129+
// Example: const hearingId = "hearing-5180"
129130
const rawHearing = await getDoc(doc(firestore, `events/hearing-${hearingId}`))
130-
if (!rawHearing.exists) return { notFound: true }
131-
131+
if (!rawHearing.exists()) return { notFound: true }
132132
const hearing = rawHearing.data() as any
133-
const transcriptionId = hearing.videoAssemblyId
134-
if (!transcriptionId) return { notFound: true }
133+
const { videoTranscriptionId, videoURL } = hearing
134+
if (!videoTranscriptionId || !videoURL) {
135+
return { notFound: true }
136+
}
135137

138+
// Example: constt videoTranscriptionId = "639e73ff-bd01-4902-bba7-88faaf39afa9"
136139
const rawTranscription = await getDoc(
137-
doc(firestore, `transcriptions/${transcriptionId}`)
140+
doc(firestore, `transcriptions/${videoTranscriptionId}`)
138141
)
139142
if (!rawTranscription.exists()) return { notFound: true }
140143
const transcription = rawTranscription.data() as any
141-
142-
const videoUrl = transcription.data().audio_url
143-
144-
const docRef = collection(
145-
firestore,
146-
`transcriptions/${transcriptionId}/utterances`
144+
console.log(
145+
`Hearing ${hearingId} was transcribed at: ${transcription.createdAt?.toDate()}`
147146
)
148-
const q = fbQuery(docRef, orderBy("start", "asc"))
149147

150-
const rawUtterances = await getDocs(q)
148+
const rawUtterances = await getDocs(
149+
fbQuery(
150+
collection(
151+
firestore,
152+
`transcriptions/${videoTranscriptionId}/utterances`
153+
),
154+
orderBy("start", "asc")
155+
)
156+
)
151157
if (rawUtterances.empty) {
152158
console.log("No utterances found")
153159
return { notFound: true }
154160
}
155-
156161
const utterances = rawUtterances.docs.map(doc => ({
157162
...doc.data(),
158163
id: doc.id
159164
}))
160165

161166
return {
162167
props: {
163-
videoUrl,
168+
videoUrl: videoURL,
164169
utterances,
165170
...(await serverSideTranslations(locale, [
166171
"auth",

0 commit comments

Comments
 (0)