mirror of
https://github.com/shumaiOne/shumai.git
synced 2026-12-04 15:14:10 +00:00
fix(video): transcribe archived videos and show progress (#560)
This commit is contained in:
@@ -9,6 +9,7 @@ import {
|
||||
import {
|
||||
selectTranscriptVideoProxyKey,
|
||||
transcriptionErrors,
|
||||
transcriptVideoStatuses,
|
||||
type GenerateTranscriptResult,
|
||||
type SavedTranscript,
|
||||
type SavedTranscriptLanguages,
|
||||
@@ -96,7 +97,7 @@ export class TranscriptService {
|
||||
where: {
|
||||
id: assetId,
|
||||
type: 'file',
|
||||
status: 'processed',
|
||||
status: { in: [...transcriptVideoStatuses] },
|
||||
isDeleted: false,
|
||||
mediaType: { startsWith: 'video/' },
|
||||
},
|
||||
@@ -173,6 +174,18 @@ export class TranscriptService {
|
||||
}
|
||||
}
|
||||
|
||||
async listActiveAssetIds(projectId: string): Promise<string[]> {
|
||||
const assets = await prisma.$queryRaw<{ assetId: string }[]>`
|
||||
SELECT DISTINCT task.asset_id AS "assetId"
|
||||
FROM workflow_tasks task
|
||||
JOIN assets asset ON asset.id = task.asset_id
|
||||
WHERE asset.project_id = ${projectId} AND NOT asset.is_deleted AND asset.type = 'file'
|
||||
AND task.type = ${type}::"WorkflowTaskType" AND task.status IN ('pending', 'processing')
|
||||
ORDER BY task.asset_id DESC
|
||||
`
|
||||
return assets.map(({ assetId }) => assetId)
|
||||
}
|
||||
|
||||
async saveResult(params: {
|
||||
taskId: string
|
||||
assetId: string
|
||||
@@ -184,7 +197,7 @@ export class TranscriptService {
|
||||
return await prisma.$transaction(async (tx) => {
|
||||
const [asset] = await tx.$queryRaw<{ id: string }[]>`
|
||||
SELECT id FROM assets
|
||||
WHERE id = ${assetId} AND NOT is_deleted AND status = 'processed'
|
||||
WHERE id = ${assetId} AND NOT is_deleted AND status::text IN (${Prisma.join(transcriptVideoStatuses)})
|
||||
FOR UPDATE
|
||||
`
|
||||
if (!asset) return false
|
||||
|
||||
Reference in New Issue
Block a user