get random
This commit is contained in:
@@ -31,7 +31,7 @@ def fetch_jokes():
|
||||
def get_random() -> str:
|
||||
count_docs = mongo.jokes_collection.count_documents({})
|
||||
rnd = random.randrange(1, count_docs + 1)
|
||||
anek = mongo.jokes_collection.aggregate([{"$sample": {"size": 1}}])[0]
|
||||
anek = mongo.jokes_collection.aggregate([{"$sample": {"size": 1}}]).next()
|
||||
return anek['text']
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user