@require_permission(Permissions.edit_data)
@requires_privilege_with_fallback(privileges.OUTBOUND_SMS)
def chat_contact_list(request, domain):
    sEcho = request.GET.get('sEcho')
    iDisplayStart = int(request.GET.get('iDisplayStart'))
    iDisplayLength = int(request.GET.get('iDisplayLength'))
    sSearch = request.GET.get('sSearch', '').strip()

    data = get_contact_info(domain)
    total_records = len(data)

    if sSearch:
        regex = re.compile(sSearch % '^.*%s.*$')
        data = filter(lambda row: regex.match(row[0]) or regex.match(row[2]), data)
    filtered_records = len(data)

    data.sort(key=lambda row: row[0])
    data = data[iDisplayStart:iDisplayStart + iDisplayLength]
    format_contact_data(domain, data)
    result = {
        'sEcho': sEcho,
        'aaData': data,
        'iTotalRecords': total_records,
        'iTotalDisplayRecords': filtered_records,
    }

    return HttpResponse(json.dumps(result))
dataset/ETHPy150Open dimagi/commcare-hq/corehq/apps/sms/views.py/chat_contact_list/swapped operands of `%`