Пример #1
0
 def handle(self, *args, **kwargs):
     q={"$and": [{"_deleted_at": {"$exists": True}}, {"_deleted_at": {"$ne": None }}]}
     cursor = xform_instances.find(q)
     c = 0
     for record in cursor:
         date_deleted = datetime_from_str(record[DELETEDAT])
         id = record[ID]
         if Instance.set_deleted_at(id, deleted_at=date_deleted):
             c += 1
         print "deleted on ", date_deleted
     print "-------------------------------"
     print "Updated %d records." % c
 def handle(self, *args, **kwargs):
     q={"$and": [{"_deleted_at": {"$exists": True}}, {"_deleted_at": {"$ne": None }}]}
     cursor = xform_instances.find(q)
     c = 0
     for record in cursor:
         date_deleted = datetime_from_str(record[DELETEDAT])
         id_string = record[XFORM_ID_STRING]
         uuid = record[UUID]
         username = record[USERFORM_ID].replace('_' + id_string, '')
         if Instance.delete_by_uuid(
                 username, id_string, uuid, deleted_at=date_deleted):
             c += 1
         print "deleted on ", date_deleted
     print "-------------------------------"
     print "Updated %d records." % c
Пример #3
0
 def handle(self, *args, **kwargs):
     q = {
         "$and": [{
             "_deleted_at": {
                 "$exists": True
             }
         }, {
             "_deleted_at": {
                 "$ne": None
             }
         }]
     }
     cursor = xform_instances.find(q)
     c = 0
     for record in cursor:
         date_deleted = datetime_from_str(record[DELETEDAT])
         id = record[ID]
         if Instance.set_deleted_at(id, deleted_at=date_deleted):
             c += 1
         print "deleted on ", date_deleted
     print "-------------------------------"
     print "Updated %d records." % c
Пример #4
0
def _get_id_for_type(record, mongo_field):
    date_field = datetime_from_str(record[mongo_field])
    mongo_str = '$' + mongo_field

    return {"$substr": [mongo_str, 0, 10]} if isinstance(date_field, datetime)\
        else mongo_str