tenders document filter
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user