Spaces:
Paused
Paused
debugging mongo
Browse files
app.py
CHANGED
|
@@ -143,14 +143,26 @@ def has_assignment_been_counted(session_id):
|
|
| 143 |
return bool(doc and doc.get("count_recorded"))
|
| 144 |
def increment_support_type_count(condition_key, support_type, session_id):
|
| 145 |
init_mongo()
|
|
|
|
|
|
|
|
|
|
|
|
|
| 146 |
|
| 147 |
-
mongo_counts_collection.update_one(
|
| 148 |
{"title": COUNTS_DOC_TITLE},
|
| 149 |
{
|
| 150 |
"$inc": {f"{condition_key}.{support_type}": 1},
|
| 151 |
"$addToSet": {f"sessions.{condition_key}.{support_type}": session_id}
|
| 152 |
}
|
| 153 |
-
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 154 |
def mark_assignment_counted(session_id, assigned_condition):
|
| 155 |
init_mongo()
|
| 156 |
mongo_collection.update_one(
|
|
|
|
| 143 |
return bool(doc and doc.get("count_recorded"))
|
| 144 |
def increment_support_type_count(condition_key, support_type, session_id):
|
| 145 |
init_mongo()
|
| 146 |
+
print("increment_support_type_count called")
|
| 147 |
+
print("condition_key:", condition_key)
|
| 148 |
+
print("support_type:", support_type)
|
| 149 |
+
print("session_id:", session_id)
|
| 150 |
|
| 151 |
+
result = mongo_counts_collection.update_one(
|
| 152 |
{"title": COUNTS_DOC_TITLE},
|
| 153 |
{
|
| 154 |
"$inc": {f"{condition_key}.{support_type}": 1},
|
| 155 |
"$addToSet": {f"sessions.{condition_key}.{support_type}": session_id}
|
| 156 |
}
|
| 157 |
+
)
|
| 158 |
+
|
| 159 |
+
print("matched_count:", result.matched_count)
|
| 160 |
+
print("modified_count:", result.modified_count)
|
| 161 |
+
|
| 162 |
+
doc = mongo_counts_collection.find_one({"title": COUNTS_DOC_TITLE})
|
| 163 |
+
print("updated doc:", doc)
|
| 164 |
+
|
| 165 |
+
|
| 166 |
def mark_assignment_counted(session_id, assigned_condition):
|
| 167 |
init_mongo()
|
| 168 |
mongo_collection.update_one(
|