Ejemplo n.º 1
0
def dropObsoleteMongoResults():

    out = []
    qset = CollectionReference.objects.all()
    referenced = [obj.collection_name for obj in qset]
    
    from sketch.mongowrapper import mongo, default_mongo_db
    collections = mongo.getDb(default_mongo_db).collection_names()
    for coll in collections:
        if coll.startswith("results"):
            if coll not in referenced:
                out.append(coll)
                mongo.dropCollection(default_mongo_db, coll)
                
    return out