Refactor tender recommendation response handling and improve test coverage
continuous-integration/drone/push Build is passing
continuous-integration/drone/push Build is passing
- Renamed the test function to `TestBuildRecommendedTenderListResponsesPreservesOrderWithoutStorage` for clarity and updated its logic to reflect changes in the recommendation response building process. - Removed unnecessary sleep in the test to enhance performance. - Refactored the `buildRecommendedTenderResponsesParallel` method to `buildRecommendedTenderListResponses`, simplifying the response building without relying on MinIO translation lookups. - Updated the repository's `mapProcedureReferencesToTenders` function to improve efficiency by grouping candidates by their contract folder IDs, enhancing the mapping process. This update streamlines the recommendation response handling and enhances the test suite for better maintainability and performance.
This commit is contained in:
@@ -947,8 +947,13 @@ func (s *tenderService) Search(ctx context.Context, form *SearchForm, pagination
|
||||
nil
|
||||
}
|
||||
|
||||
const recommendRequestTimeout = 15 * time.Second
|
||||
|
||||
// Recommend retrieves AI-ranked tenders for the authenticated customer's company.
|
||||
func (s *tenderService) Recommend(ctx context.Context, form *SearchForm, pagination *response.Pagination) (*SearchResponse, error) {
|
||||
ctx, cancel := context.WithTimeout(ctx, recommendRequestTimeout)
|
||||
defer cancel()
|
||||
|
||||
companyIDs := normalizeRecommendationCompanyScope(form.CompanyIDs)
|
||||
companyID := ""
|
||||
if form.CompanyID != nil {
|
||||
@@ -1055,7 +1060,7 @@ func (s *tenderService) Recommend(ctx context.Context, form *SearchForm, paginat
|
||||
end = len(ordered)
|
||||
}
|
||||
|
||||
paged := s.buildRecommendedTenderResponsesParallel(ctx, ordered[start:end], lang)
|
||||
paged := s.buildRecommendedTenderListResponses(ordered[start:end], lang)
|
||||
|
||||
return &SearchResponse{
|
||||
Tenders: paged,
|
||||
|
||||
Reference in New Issue
Block a user