Refactor tender service methods for rejected tenders and enhance unit tests
continuous-integration/drone/push Build is passing

- Renamed `buildRejectedTenderIDSetForCompanies` to `buildRejectedTenderIDSetsForCompanies` to better reflect its functionality of returning a map of excluded tender IDs by company.
- Updated the implementation to return a nested map structure for better organization of excluded tender IDs per company.
- Added a new test function `TestIsRecommendedTenderExcludedForAllCompanies` to validate the visibility of tenders based on company-specific exclusions.
- Enhanced existing tests to ensure comprehensive coverage of the new logic for handling rejected tenders.

This update improves the clarity and functionality of the tender recommendation process by refining the handling of rejected tenders and expanding test coverage.
This commit is contained in:
Mazyar
2026-07-04 13:56:07 +03:30
parent 4c48e0bb3b
commit 3221a31ac8
3 changed files with 74 additions and 19 deletions
+10 -3
View File
@@ -973,10 +973,13 @@ func (s *tenderService) Recommend(ctx context.Context, form *SearchForm, paginat
return nil, err
}
var excluded map[string]struct{}
var (
excluded map[string]struct{}
excludedByCompany map[string]map[string]struct{}
)
if form.ExcludeRejectedTenders {
if len(companyIDs) > 0 {
excluded, err = s.buildRejectedTenderIDSetForCompanies(ctx, companyIDs)
excludedByCompany, err = s.buildRejectedTenderIDSetsForCompanies(ctx, companyIDs)
} else {
excluded, err = s.buildRejectedTenderIDSet(ctx, companyID)
}
@@ -999,7 +1002,11 @@ func (s *tenderService) Recommend(ctx context.Context, form *SearchForm, paginat
if !ok {
continue
}
if isRecommendedTenderExcluded(tender, tenderRef, excluded) {
if len(companyIDs) > 0 {
if isRecommendedTenderExcludedForAllCompanies(tender, tenderRef, excludedByCompany, companyIDs) {
continue
}
} else if isRecommendedTenderExcluded(tender, tenderRef, excluded) {
continue
}
if form.OnlyActiveDeadlines && !tender.IsRecommendable(now) {