1
Fork 0
mirror of https://github.com/Steffo99/unimore-bda-6.git synced 2024-11-21 23:44:19 +00:00

Fix MongoDB queries

This commit is contained in:
Steffo 2023-02-01 16:02:52 +01:00
parent c2e195845e
commit f544850403
Signed by: steffo
GPG key ID: 2A24051445686895

View file

@ -58,7 +58,7 @@ def sample_reviews_by_rating(reviews: pymongo.collection.Collection, rating: flo
"""
return reviews.aggregate([
{"$filter": {"overall": rating}},
{"$match": {"overall": rating}},
{"$sample": {"size": amount}},
])
@ -69,7 +69,14 @@ def sample_reviews_by_rating_polar(reviews: pymongo.collection.Collection, amoun
"""
return reviews.aggregate([
{"$filter": {"overall": {"$or": [1.0, 5.0]}}},
{"$match":
{"$or":
[
{"overall": 1.0},
{"overall": 5.0},
]
},
},
{"$sample": {"size": amount}},
])