Add IsRecommendable method and corresponding tests for Tender entity
continuous-integration/drone/push Build is passing

- Implemented the IsRecommendable method in the Tender entity to determine if a tender should be included in AI recommendations based on its status and deadline.
- Added unit tests for the IsRecommendable method to cover various scenarios, ensuring accurate recommendation logic.
- Updated the Recommend method in the tender service to utilize the new IsRecommendable method for improved clarity and functionality.

This update enhances the recommendation logic for tenders, ensuring only appropriate tenders are considered for AI recommendations based on their status and deadlines.
This commit is contained in:
Mazyar
2026-06-30 17:22:06 +03:30
parent 86789dcd20
commit ff6bdfcb09
3 changed files with 72 additions and 3 deletions
+11 -2
View File
@@ -955,10 +955,10 @@ func (s *tenderService) Recommend(ctx context.Context, form *SearchForm, paginat
if !ok {
continue
}
if form.OnlyActiveDeadlines && tender.TenderDeadline <= now {
if form.OnlyActiveDeadlines && !tender.IsRecommendable(now) {
continue
}
if len(form.Status) > 0 && tender.Status != TenderStatusActive {
if len(form.Status) > 0 && !statusAllowed(tender.Status, form.Status) {
continue
}
@@ -985,6 +985,15 @@ func (s *tenderService) Recommend(ctx context.Context, form *SearchForm, paginat
}, nil
}
func statusAllowed(status TenderStatus, allowed []string) bool {
for _, s := range allowed {
if string(status) == strings.TrimSpace(s) {
return true
}
}
return false
}
// Delete deletes a tender
// GetTenderStatistics retrieves tender statistics