save id, url, thumbnail and createdAt in the digest

This commit is contained in:
Hongbo Wu 2024-04-17 09:58:11 +08:00
parent 6bfb4842e2
commit 47fd4d9663
2 changed files with 18 additions and 4 deletions

View file

@ -365,6 +365,12 @@ export const createDigestJob = async (jobData: CreateDigestJobData) => {
urlsToAudio: [],
jobState: 'completed',
speechFiles,
libraryItems: filteredSummaries.map((item) => ({
id: item.libraryItem.id,
url: item.libraryItem.originalUrl,
thumbnail: item.libraryItem.thumbnail ?? undefined,
})),
createdAt: new Date(),
}
await writeDigest(jobData.userId, digest)

View file

@ -2,9 +2,20 @@ import { redisDataSource } from '../redis_data_source'
import { SpeechFile } from '@omnivore/text-to-speech-handler'
import { logger } from '../utils/logger'
interface Chapter {
title: string
}
interface LibraryItem {
id: string
url: string
thumbnail?: string
}
export interface Digest {
id: string
jobState: string
createdAt: Date
url?: string
title?: string
@ -13,10 +24,7 @@ export interface Digest {
urlsToAudio?: string[]
speechFiles?: SpeechFile[]
}
interface Chapter {
title: string
libraryItems?: LibraryItem[]
}
const digestKey = (userId: string) => `digest:${userId}`