@register.simple_tag
def aggregate_section_totals(section_name, results_arr, daily):
    """Hackish function to do a summation of a section in the org_report"""    
    #go through the array and go to the index that my section name is
    startindex = -1
    endindex = -1
    for itemarr in results_arr:
        if itemarr[1] == section_name:
            startindex = results_arr.index(itemarr)
            continue
        
        if 0 >= startindex:
            if itemarr[1] != None:
                endindex = results_arr.index(itemarr)
                break
    
    
    summation = []
    section_arr = []
    if endindex == -1:
        section_arr = results_arr[startindex:]
    else:
        section_arr = results_arr[startindex:endindex+1]
        
    for itemarr in section_arr:
        if summation == []:
            summation = summation + itemarr[-1]
        else:
            for i in range(0,len(itemarr[-1])):
                summation[i] += itemarr[-1][i]
                
    ret = ''
    if daily:        
        for item in summation:
            ret += '<td style="background:#99FFFF"><strong>%d</strong></td>' % item
    else:
        sum = 0
        for item in summation:
            sum += item
        ret = "<td>%d</td>" % sum
    return ret
dataset/ETHPy150Open dimagi/commcare-hq/corehq/apps/hqwebapp/templatetags/mainreport_tags.py/aggregate_section_totals/swapped operands of `>=`