def _create(user):
        # Pull all the records that need to be rolled back
        logger.info("Finding activities for %s" % user["_id"])
        conns = User.GetConnectionRecordsByUser(user)
        my_services = [conn.Service.ID for conn in conns]
        my_ext_ids = [conn.ExternalID for conn in conns]
        logger.info("Scanning uploads table for %s accounts with %s extids" % (my_services, my_ext_ids))
        uploads = db.uploaded_activities.find({"Service": {"$in": my_services}, "UserExternalID": {"$in": my_ext_ids}})
        pending_deletions = {}
        for upload in uploads:
            svc = upload["Service"]
            upload_id = upload["ExternalID"]
            svc_ext_id = upload["UserExternalID"]
            # Filter back down to the pairing we actually need
            if my_services.index(svc) != my_ext_ids.index(svc_ext_id):
                continue
            if svc not in pending_deletions:
                pending_deletions[svc] = []
            pending_deletions[svc].append(upload_id)

        # Another case of "I should have an ORM"
        return RollbackTask({"PendingDeletions": pending_deletions})
dataset/ETHPy150Open cpfair/tapiriik/tapiriik/services/rollback.py/RollbackTask._create/original