Skip to content

Commit e054c49

Browse files
committed
Address further review feedback on transcriptions system.
1 parent f16f46e commit e054c49

File tree

2 files changed

+15
-13
lines changed

2 files changed

+15
-13
lines changed

functions/src/events/scrapeEvents.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,11 +197,12 @@ const shouldScrapeVideo = async (EventId: number) => {
197197
.doc(`hearing-${String(EventId)}`)
198198
.get()
199199
const eventData = eventInDb.data()
200+
200201
if (!eventData) {
201202
return false
202203
}
203204
if (!eventData.videoFetchedAt) {
204-
return withinCutoff(new Date(eventData.StartTime))
205+
return withinCutoff(new Date(Hearing.check(eventData).startsAt.toDate()))
205206
}
206207
return false
207208
}

functions/src/webhooks/transcription.ts

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import * as functions from "firebase-functions"
22
import { AssemblyAI } from "assemblyai"
3-
import { db } from "../firebase"
3+
import { db, Timestamp } from "../firebase"
44
import { sha256 } from "js-sha256"
55

66
const assembly = new AssemblyAI({
@@ -29,7 +29,6 @@ export const transcription = functions.https.onRequest(async (req, res) => {
2929
.doc("webhookAuth")
3030
.get()
3131
const tokenInDbData = tokenInDb.data()
32-
console.log("tokenInDbData", tokenInDbData)
3332

3433
if (tokenInDbData) {
3534
return hashedToken === tokenInDbData.videoAssemblyWebhookToken
@@ -41,19 +40,18 @@ export const transcription = functions.https.onRequest(async (req, res) => {
4140
const { id, text, audio_url, utterances, words } = transcript
4241
if (authenticatedEventsInDb) {
4342
try {
44-
const transcriptionInDb = db
43+
const transcriptionInDb = await db
4544
.collection("transcriptions")
4645
.doc(transcript.id)
4746

48-
transcriptionInDb.set({
47+
await transcriptionInDb.set({
4948
id,
5049
text,
51-
timestamp: new Date(),
52-
audio_url,
53-
words
50+
createdAt: Timestamp.now(),
51+
audio_url
5452
})
5553

56-
transcriptionInDb
54+
await transcriptionInDb
5755
.collection("timestamps")
5856
.doc("utterances")
5957
.set({
@@ -68,14 +66,17 @@ export const transcription = functions.https.onRequest(async (req, res) => {
6866
)
6967
})
7068

71-
transcriptionInDb.collection("timestamps").doc("words").set({
72-
words
73-
})
69+
await transcriptionInDb
70+
.collection("timestamps")
71+
.doc("words")
72+
.set({
73+
words
74+
})
7475

7576
const batch = db.batch()
7677

7778
batch.set(db.collection("transcriptions").doc(transcript.id), {
78-
_timestamp: new Date(),
79+
_timestamp: Timestamp.now(),
7980
...transcript
8081
})
8182

0 commit comments

Comments
 (0)