tenders document filter

This commit is contained in:
Mazyar
2026-05-20 16:03:30 +03:30
parent aa5e547d7b
commit 4390d7e1a6
3 changed files with 21 additions and 0 deletions
+17
View File
@@ -1058,5 +1058,22 @@ func (r *tenderRepository) buildSearchFilter(form *SearchForm) bson.M {
filter["notice_language_code"] = bson.M{"$in": dedupeNonEmptyStrings(form.Languages)}
}
if form.DocumentsScraped {
scrapedClause := bson.M{
"$or": []bson.M{
{"processing_metadata.documents_scraped": true},
{"scraped_documents.0": bson.M{"$exists": true}},
},
}
if len(filter) == 0 {
return scrapedClause
}
if and, ok := filter["$and"].([]bson.M); ok {
filter["$and"] = append(and, scrapedClause)
} else {
filter["$and"] = []bson.M{filter, scrapedClause}
}
}
return filter
}