fix article generation task status logging
This commit is contained in:
@@ -3,6 +3,8 @@ package app
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/jackc/pgx/v5/pgxpool"
|
||||
@@ -389,14 +391,17 @@ func HandleKolGenerationTaskFailure(
|
||||
quotaRepo := repository.NewQuotaRepository(pool)
|
||||
usageRepo := repository.NewKolUsageRepository(pool)
|
||||
|
||||
var failureErr error
|
||||
if task.ID > 0 {
|
||||
_ = auditRepo.UpdateGenerationTaskStatus(cleanupCtx, repository.GenerationTaskStatusInput{
|
||||
if err := auditRepo.UpdateGenerationTaskStatus(cleanupCtx, repository.GenerationTaskStatusInput{
|
||||
ID: task.ID,
|
||||
TenantID: task.TenantID,
|
||||
Status: "failed",
|
||||
ErrorMessage: &errMsg,
|
||||
CompletedAt: &now,
|
||||
})
|
||||
}); err != nil {
|
||||
failureErr = errors.Join(failureErr, fmt.Errorf("update generation task failed status: %w", err))
|
||||
}
|
||||
_ = auditRepo.UpdateTaskRecordStatus(cleanupCtx, repository.TaskRecordInput{
|
||||
TenantID: task.TenantID,
|
||||
TaskType: kolGenerationTaskRecordType,
|
||||
@@ -409,7 +414,9 @@ func HandleKolGenerationTaskFailure(
|
||||
}
|
||||
|
||||
if task.ArticleID > 0 {
|
||||
_ = articleRepo.UpdateArticleGenerateStatus(cleanupCtx, task.ArticleID, task.TenantID, "failed")
|
||||
if err := articleRepo.UpdateArticleGenerateStatus(cleanupCtx, task.ArticleID, task.TenantID, "failed"); err != nil {
|
||||
failureErr = errors.Join(failureErr, fmt.Errorf("update article failed status: %w", err))
|
||||
}
|
||||
}
|
||||
|
||||
if task.QuotaReservationID > 0 {
|
||||
@@ -433,5 +440,5 @@ func HandleKolGenerationTaskFailure(
|
||||
}
|
||||
|
||||
InvalidateArticleCaches(cleanupCtx, cache, task.TenantID, &task.ArticleID)
|
||||
return nil
|
||||
return failureErr
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user