skip = 0 limit = 100 while has_more: resp = api.get( 'task', params={ 'assigned_to': user_id, '_skip': skip, '_limit': limit, '_fields': 'id', }, ) task_ids.extend(t['id'] for t in resp['data']) has_more = resp['has_more'] skip += limit if args.verbose: print(f'Found {len(task_ids)} tasks') if not args.confirmed: print( 'This is a dry run, so the tasks are not deleted. Use the --confirmed flag to delete them.' ) sys.exit(0) total_cnt = len(task_ids) for idx, task_id in enumerate(task_ids): api.delete('task/' + task_id) if args.verbose: print(f'Deleting {(idx + 1)}/{total_cnt}')
if args.verbose: print 'Gathering tasks for %s (%d/%d)' % (user_id, idx + 1, total_cnt) has_more = True skip = 0 limit = 100 while has_more: resp = api.get('task', params={ 'assigned_to': user_id, '_skip': skip, '_limit': limit, '_fields': 'id', }) task_ids.extend(t['id'] for t in resp['data']) has_more = resp['has_more'] skip += limit if args.verbose: print 'Found %d tasks' % len(task_ids) if not args.confirmed: print 'This is a dry run, so the tasks are not deleted. Use the --confirmed flag to delete them.' sys.exit(0) total_cnt = len(task_ids) for idx, task_id in enumerate(task_ids): api.delete('task/' + task_id) if args.verbose: print 'Deleting %d/%d' % (idx + 1, total_cnt)