Add deduplication and normalization for tender recommendations
continuous-integration/drone/push Build is passing

- Introduced a new function `dedupeRecommendationResponsesByTenderID` to remove duplicate tender recommendations based on their IDs, ensuring unique entries in the recommendation list.
- Updated the `mergeRecommendedTenders` function to utilize the new deduplication logic, streamlining the merging process of recommendation lists.
- Enhanced the `fetchAIRecommendations` method to apply deduplication on the fetched recommendations, improving data integrity.
- Added unit tests for the new deduplication function to validate its behavior and ensure correct handling of various input scenarios.

This update enhances the recommendation handling by ensuring that duplicate tender entries are effectively managed, improving the overall quality of the recommendations provided to users.
This commit is contained in:
Mazyar
2026-07-07 23:00:16 +03:30
parent 1ad0206e61
commit 4e5296d5dd
5 changed files with 89 additions and 16 deletions
+20
View File
@@ -2,6 +2,26 @@ package company
import "testing"
func TestDedupeRecommendationResponsesByTenderID(t *testing.T) {
input := []RecommendedTenderResponse{
{Rank: 1, TenderID: " PROC-1 ", Analysis: " first "},
{Rank: 2, TenderID: "PROC-2", Analysis: "second"},
{Rank: 1, TenderID: "PROC-2", Analysis: "duplicate"},
{Rank: 4, TenderID: " ", Analysis: "ignored"},
}
got := dedupeRecommendationResponsesByTenderID(input)
if len(got) != 2 {
t.Fatalf("dedupeRecommendationResponsesByTenderID() len = %d, want 2", len(got))
}
if got[0].TenderID != "PROC-1" || got[0].Analysis != "first" {
t.Fatalf("first recommendation = %+v, want trimmed PROC-1/first", got[0])
}
if got[1].TenderID != "PROC-2" || got[1].Rank != 2 {
t.Fatalf("second recommendation = %+v, want original PROC-2 rank 2", got[1])
}
}
func TestMergeRecommendedTenders(t *testing.T) {
first := []RecommendedTenderResponse{
{Rank: 1, TenderID: " PROC-1 ", Analysis: " first "},