Minio document json

This commit is contained in:
Mazyar
2026-05-13 18:24:45 +03:30
parent 5ab6b2714e
commit eaa681814d
2 changed files with 50 additions and 17 deletions
+26 -14
View File
@@ -160,22 +160,24 @@ func (s *StorageClient) getSummaryFromObjectKey(ctx context.Context, objectKey,
return "", fmt.Errorf("ai_summarizer: failed to parse tender.json: %w", err)
}
if !tenderJSON.SummarizeStatus.Done {
done, overall := tenderJSON.resolved()
if !done {
return "", ErrSummaryNotReady
}
if tenderJSON.OverallSummary == nil || *tenderJSON.OverallSummary == "" {
if overall == nil || strings.TrimSpace(*overall) == "" {
return "", ErrNoOverallSummary
}
summaryText := strings.TrimSpace(*overall)
s.logger.Info("Retrieved overall_summary from storage", map[string]interface{}{
"contract_folder_id": contractFolderID,
"notice_id": noticePublicationID,
"object_key": objectKey,
"summary_length": len(*tenderJSON.OverallSummary),
"summary_length": len(summaryText),
})
return *tenderJSON.OverallSummary, nil
return summaryText, nil
}
// IsSummaryReady is a convenience method that checks whether the tender.json
@@ -207,7 +209,8 @@ func (s *StorageClient) IsSummaryReady(ctx context.Context, contractFolderID, no
return false, fmt.Errorf("ai_summarizer: failed to parse tender.json: %w", err)
}
return tenderJSON.SummarizeStatus.Done, nil
done, _ := tenderJSON.resolved()
return done, nil
}
// ListDocuments lists document files stored under
@@ -351,19 +354,28 @@ func (s *StorageClient) GetAllSummaries(ctx context.Context) ([]TenderSummaryIte
summary, err = s.getSummaryFromObjectKey(ctx, key, contractFolderID, noticePublicationID)
}
if err != nil {
s.logger.Debug("Skipping tender summary", map[string]interface{}{
"object_key": key,
"contract_folder_id": contractFolderID,
"notice_id": noticePublicationID,
"error": err.Error(),
})
if errors.Is(err, ErrSummaryNotReady) {
switch {
case errors.Is(err, ErrSummaryNotReady):
results = append(results, TenderSummaryItem{
ContractFolderID: contractFolderID,
NoticeID: noticePublicationID,
Done: false,
})
case errors.Is(err, ErrNoOverallSummary):
// File exists and pipeline reports done, but no summary text yet (or empty).
results = append(results, TenderSummaryItem{
ContractFolderID: contractFolderID,
NoticeID: noticePublicationID,
OverallSummary: "",
Done: true,
})
default:
s.logger.Debug("Skipping tender summary", map[string]interface{}{
"object_key": key,
"contract_folder_id": contractFolderID,
"notice_id": noticePublicationID,
"error": err.Error(),
})
}
continue
}