@@ -122,45 +122,50 @@ function formatTime(ms: number) {
122
122
123
123
export const getServerSideProps : GetServerSideProps = async ctx => {
124
124
const locale = ctx . locale ?? ctx . defaultLocale ?? "en"
125
- const query = Query . safeParse ( ctx . query )
125
+ const query = Query . safeParse ( ctx . params )
126
126
if ( ! query . success ) return { notFound : true }
127
127
const { hearingId } = query . data
128
128
129
+ // Example: const hearingId = "hearing-5180"
129
130
const rawHearing = await getDoc ( doc ( firestore , `events/hearing-${ hearingId } ` ) )
130
- if ( ! rawHearing . exists ) return { notFound : true }
131
-
131
+ if ( ! rawHearing . exists ( ) ) return { notFound : true }
132
132
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
+ }
135
137
138
+ // Example: constt videoTranscriptionId = "639e73ff-bd01-4902-bba7-88faaf39afa9"
136
139
const rawTranscription = await getDoc (
137
- doc ( firestore , `transcriptions/${ transcriptionId } ` )
140
+ doc ( firestore , `transcriptions/${ videoTranscriptionId } ` )
138
141
)
139
142
if ( ! rawTranscription . exists ( ) ) return { notFound : true }
140
143
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 ( ) } `
147
146
)
148
- const q = fbQuery ( docRef , orderBy ( "start" , "asc" ) )
149
147
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
+ )
151
157
if ( rawUtterances . empty ) {
152
158
console . log ( "No utterances found" )
153
159
return { notFound : true }
154
160
}
155
-
156
161
const utterances = rawUtterances . docs . map ( doc => ( {
157
162
...doc . data ( ) ,
158
163
id : doc . id
159
164
} ) )
160
165
161
166
return {
162
167
props : {
163
- videoUrl,
168
+ videoUrl : videoURL ,
164
169
utterances,
165
170
...( await serverSideTranslations ( locale , [
166
171
"auth" ,
0 commit comments