Add IsRecommendable method and corresponding tests for Tender entity
continuous-integration/drone/push Build is passing
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:
@@ -262,11 +262,22 @@ func (t *Tender) IsExpired() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
// Check if deadline (in milliseconds) is in the past
|
||||
now := time.Now().Unix()
|
||||
return t.TenderDeadline < now
|
||||
}
|
||||
|
||||
// IsRecommendable reports whether a tender should appear in AI recommendation results.
|
||||
func (t *Tender) IsRecommendable(now int64) bool {
|
||||
switch t.Status {
|
||||
case TenderStatusExpired, TenderStatusCancelled, TenderStatusAwarded, TenderStatusClosed:
|
||||
return false
|
||||
}
|
||||
if t.TenderDeadline <= now {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
// GetTenderURL returns the TED tender URL
|
||||
func (t *Tender) GetTenderURL() string {
|
||||
if t.TenderURL != "" {
|
||||
|
||||
Reference in New Issue
Block a user