843e1508df
continuous-integration/drone/push Build is passing
- Updated the tender search handler to include a new `include_total` query parameter, allowing clients to request total count and pagination metadata for search results. - Refactored the `tenderSearchListProjection` to exclude heavy fields from the list response, optimizing data retrieval. - Modified the `buildSearchFilter` method to utilize the `processing_metadata.documents_scraped` flag for filtering, improving search accuracy. - Added unit tests for the new pagination features and search filter logic, ensuring robust validation of the search functionality. This update significantly enhances the tender search experience by providing more flexible pagination options and improving the efficiency of data handling.
30 lines
715 B
Go
30 lines
715 B
Go
package tender
|
|
|
|
import (
|
|
"testing"
|
|
)
|
|
|
|
func TestBuildSearchFilterDocumentsScrapedUsesMongoFlag(t *testing.T) {
|
|
repo := &tenderRepository{}
|
|
filter := repo.buildSearchFilter(&SearchForm{DocumentsScraped: true})
|
|
|
|
if filter["processing_metadata.documents_scraped"] != true {
|
|
t.Fatalf("expected mongo documents_scraped flag, got %#v", filter)
|
|
}
|
|
}
|
|
|
|
func TestTenderSearchListProjectionExcludesHeavyFields(t *testing.T) {
|
|
projection := tenderSearchListProjection()
|
|
for _, field := range []string{
|
|
"content_xml",
|
|
"description",
|
|
"ai_overall_summary",
|
|
"procurement_lots",
|
|
"document_summaries",
|
|
} {
|
|
if projection[field] != 0 {
|
|
t.Fatalf("expected %s to be excluded from list projection", field)
|
|
}
|
|
}
|
|
}
|