tender summary refactor

This commit is contained in:
Mazyar
2026-05-19 19:03:50 +03:30
parent 92d4b14b33
commit fcf2cae6bc
3 changed files with 41 additions and 25 deletions
+8 -8
View File
@@ -278,13 +278,15 @@ func (s *StorageClient) resolveNoticeStoragePrefix(ctx context.Context, contract
// GetSummaryFromStorage fetches the
// PROC_<contractFolderID>/<noticePublicationID>/tender.json file from the AI
// service's MinIO bucket, parses it, and returns the overall_summary string.
// service's MinIO bucket, parses it, and returns the tender summary text.
//
// Summary text is read from summary (current) or overall_summary (legacy).
//
// It returns:
// - (summary, nil) on success
// - ("", ErrObjectNotFound) if the tender.json does not exist (404)
// - ("", ErrSummaryNotReady) if the file exists but summarize_status.done is false
// - ("", ErrNoOverallSummary) if done is true but overall_summary is empty/null
// - ("", ErrNoOverallSummary) if done is true but summary text is empty
// - ("", error) for any other failure
func (s *StorageClient) GetSummaryFromStorage(ctx context.Context, contractFolderID, noticePublicationID string) (string, error) {
if strings.TrimSpace(contractFolderID) == "" {
@@ -352,7 +354,7 @@ func (s *StorageClient) getTranslationFromObjectKey(ctx context.Context, objectK
return entry, nil
}
// getSummaryFromObjectKey reads tender.json at objectKey and returns overall_summary when ready.
// getSummaryFromObjectKey reads tender.json at objectKey and returns summary text when ready.
// contractFolderID and noticePublicationID are used for logging only (may be empty when unknown).
func (s *StorageClient) readTenderJSONAtKey(ctx context.Context, objectKey string) (*TenderJSON, error) {
object, err := s.client.GetObject(ctx, s.config.MinioBucket, objectKey, minio.GetObjectOptions{})
@@ -403,17 +405,15 @@ func (s *StorageClient) getSummaryFromObjectKey(ctx context.Context, objectKey,
return "", err
}
done, overall := tenderJSON.resolved()
done, summaryText := tenderJSON.resolved()
if !done {
return "", ErrSummaryNotReady
}
if overall == nil || strings.TrimSpace(*overall) == "" {
if summaryText == "" {
return "", ErrNoOverallSummary
}
summaryText := strings.TrimSpace(*overall)
s.logger.Info("Retrieved overall_summary from storage", map[string]interface{}{
s.logger.Info("Retrieved tender summary from storage", map[string]interface{}{
"contract_folder_id": contractFolderID,
"notice_id": noticePublicationID,
"object_key": objectKey,