Closed toconnell closed 6 months ago
Yeah, that was it. Pretty easy:
diff --git a/app/world/__init__.py b/app/world/__init__.py
index 08a40c8..5d377ae 100644
--- a/app/world/__init__.py
+++ b/app/world/__init__.py
@@ -639,7 +639,7 @@ class World(object):
'$group': {
'_id': '$' + attrib, # Group by the 'attrib' field
'count': {'$sum': 1}, # Increment count for each group
- attrib: {'$first': '$name'},
+ attrib: {'$first': '$' + attrib},
}
},
{
Leads tto:
toconnell@mona:~/kdm-manager-api$ ./world.sh --debug top_causes_of_death
comment: Most popular causes of survivor death across all settlements
created_on: 2024-03-07 10:32:13.318292
handle: top_causes_of_death
max_age: 30
name: Top causes of death
value: [{'_id': 'Bled out', 'count': 877, 'cause_of_death': 'Bled out'}, {'_id': 'Decapitated', 'count': 513, 'cause_of_death': 'Decapitated'}, {'_id': 'Childbirth', 'count': 402, 'cause_of_death': 'Childbirth'}, {'_id': 'Murdered', 'count': 362, 'cause_of_death': 'Murdered'}, {'_id': 'Head Explosion!', 'count': 359, 'cause_of_death': 'Head Explosion!'}, {'_id': 'Instant death', 'count': 348, 'cause_of_death': 'Instant death'}, {'_id': 'Intimacy', 'count': 331, 'cause_of_death': 'Intimacy'}, {'_id': 'Armored Strangers', 'count': 291, 'cause_of_death': 'Armored Strangers'}, {'_id': 'Mortal Terror', 'count': 273, 'cause_of_death': 'Mortal Terror'}, {'_id': 'Plague', 'count': 230, 'cause_of_death': 'Plague'}]
value_type: list
See '/home/toconnell/kdm-manager-api/logs/world.log' for complete query debug info!
toconnell@mona:~/kdm-manager-api$ ./world.sh --debug top_survivor_names
comment: Most popular survivor names across all settlements
created_on: 2024-03-07 10:32:15.974748
handle: top_survivor_names
limit: 10
max_age: 30
name: Top Survivor names
value: [{'_id': 'Adam', 'count': 155, 'name': 'Adam'}, {'_id': 'Lucy', 'count': 135, 'name': 'Lucy'}, {'_id': 'Zachary', 'count': 113, 'name': 'Zachary'}, {'_id': 'Anna', 'count': 109, 'name': 'Anna'}, {'_id': 'Allister', 'count': 98, 'name': 'Allister'}, {'_id': 'Quinn', 'count': 97, 'name': 'Quinn'}, {'_id': 'Ezra', 'count': 86, 'name': 'Ezra'}, {'_id': 'Paul', 'count': 81, 'name': 'Paul'}, {'_id': 'Raven', 'count': 78, 'name': 'Raven'}, {'_id': 'Mary', 'count': 74, 'name': 'Mary'}]
value_type: list
Likely related to recent mongo query refactor operations having 'name' as a literal.