ai-tube / src /app /server /actions /ai-tube-hf /extendVideosWithStats.ts
jbilcke-hf's picture
jbilcke-hf HF staff
just a lil bit of plumbing
1185ec1
raw
history blame
No virus
562 Bytes
"use server"
import { VideoInfo } from "@/types/general"
import { getStatsForVideos } from "../stats"
export async function extendVideosWithStats(videos: VideoInfo[]): Promise<VideoInfo[]> {
const allStats = await getStatsForVideos(videos.map(v => v.id))
return videos.map(v => {
const stats = allStats[v.id] || {
numberOfViews: 0,
numberOfLikes: 0,
numberOfDislikes: 0
}
v.numberOfViews = stats.numberOfViews
v.numberOfLikes = stats.numberOfLikes
v.numberOfDislikes = stats.numberOfDislikes
return v
})
}