Spaces:
Runtime error
Runtime error
Update database.py
Browse files- database.py +12 -5
database.py
CHANGED
|
@@ -1,9 +1,7 @@
|
|
| 1 |
from pymongo import MongoClient
|
| 2 |
-
from urllib.parse import quote_plus
|
| 3 |
import os
|
| 4 |
|
| 5 |
-
password =
|
| 6 |
-
|
| 7 |
uri = f"mongodb+srv://cidar:{password}@cluster0.yuhfxcj.mongodb.net/?retryWrites=true&w=majority"
|
| 8 |
|
| 9 |
# Create a new client and connect to the server
|
|
@@ -28,8 +26,17 @@ def read_responses(filter_query=None):
|
|
| 28 |
try:
|
| 29 |
if filter_query is None:
|
| 30 |
filter_query = {} # An empty query will return all documents
|
| 31 |
-
|
| 32 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 33 |
except Exception as e:
|
| 34 |
print(f"An error occurred: {e}")
|
| 35 |
return []
|
|
|
|
| 1 |
from pymongo import MongoClient
|
|
|
|
| 2 |
import os
|
| 3 |
|
| 4 |
+
password = os.environ.get('password')
|
|
|
|
| 5 |
uri = f"mongodb+srv://cidar:{password}@cluster0.yuhfxcj.mongodb.net/?retryWrites=true&w=majority"
|
| 6 |
|
| 7 |
# Create a new client and connect to the server
|
|
|
|
| 26 |
try:
|
| 27 |
if filter_query is None:
|
| 28 |
filter_query = {} # An empty query will return all documents
|
| 29 |
+
|
| 30 |
+
ranks = {
|
| 31 |
+
'CIDAR': [0, 0, 0],
|
| 32 |
+
'ALPAGASUS': [0, 0, 0],
|
| 33 |
+
'CHAT': [0, 0, 0],
|
| 34 |
+
}
|
| 35 |
+
|
| 36 |
+
for doc in collection.find(filter_query):
|
| 37 |
+
for model in ranks:
|
| 38 |
+
ranks[model][doc[model] - 1] += 1
|
| 39 |
+
return ranks
|
| 40 |
except Exception as e:
|
| 41 |
print(f"An error occurred: {e}")
|
| 42 |
return []
|