fix article generation task status logging
This commit is contained in:
@@ -2,6 +2,7 @@ package app
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"strings"
|
||||
"time"
|
||||
@@ -61,15 +62,20 @@ func HandleClaimedGenerationTaskFailure(
|
||||
articleRepo := repository.NewArticleRepository(pool)
|
||||
quotaRepo := repository.NewQuotaRepository(pool)
|
||||
|
||||
_ = auditRepo.UpdateGenerationTaskStatus(cleanupCtx, repository.GenerationTaskStatusInput{
|
||||
var failureErr error
|
||||
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))
|
||||
}
|
||||
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 {
|
||||
@@ -119,7 +125,7 @@ func HandleClaimedGenerationTaskFailure(
|
||||
promptRuleService.streams.Fail(task.ArticleID, task.ID, title, errMsg)
|
||||
}
|
||||
|
||||
return nil
|
||||
return failureErr
|
||||
}
|
||||
|
||||
func (s *TemplateService) ProcessQueuedTask(ctx context.Context, task ClaimedGenerationTask) {
|
||||
|
||||
Reference in New Issue
Block a user