2014-05-08 21:30:37 -04:00
|
|
|
// Finds all patches and denorms their target names and creators.
|
|
|
|
|
|
|
|
var patches = db.patches.find({status:'pending'}).toArray();
|
|
|
|
for(var i in patches) {
|
|
|
|
var patch = patches[i];
|
|
|
|
var collection = null;
|
|
|
|
if(patch.target.collection === 'level') collection = db.levels;
|
|
|
|
if(patch.target.collection === 'level_component') collection = db.level.components;
|
|
|
|
if(patch.target.collection === 'level_system') collection = db.level.systems;
|
2014-06-24 17:24:37 -04:00
|
|
|
if(patch.target.collection === 'thang_type') collection = db.level.thang.types;
|
|
|
|
if(collection === null) {
|
|
|
|
print('could not find collection', patch.target.collection);
|
|
|
|
continue;
|
|
|
|
}
|
2014-05-08 21:30:37 -04:00
|
|
|
var target = collection.findOne({original:patch.target.original, name:{$exists:true}});
|
|
|
|
var creator = db.users.findOne({_id:patch.creator});
|
2014-06-24 17:24:37 -04:00
|
|
|
if(target === null) {
|
|
|
|
print('No target for patch from', patch.target.collection);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if(creator === null) {
|
|
|
|
print(target.name, 'made by unknown person...');
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2014-05-08 21:30:37 -04:00
|
|
|
print(target.name, 'made by', creator.name);
|
|
|
|
}
|