Exemplo n.º 1
0
def get_summary_org_test(results):
    from iatidq import dqorganisations, dqtests
    orgtests = set(map(lambda x: (x['organisation_id'], x['test_id']), results))
    ot = []

    for orgtest in orgtests:
        orgtest_results = filter(lambda x: (
                x['organisation_id'] == orgtest[0] and 
                x['test_id'] == orgtest[1]
                ), results)

        success = filter(lambda x: x['response'] == 1, orgtest_results)
        fail    = filter(lambda x: x['response'] != 1, orgtest_results)
        
        totalsuccess = sum(map(lambda x: x['count'], success))
        totalfail    = sum(map(lambda x: x['count'], fail))
        
        pct = float(totalsuccess) / (totalsuccess + totalfail) * 100

        passfail = pct >= 50.0

        if passfail:
            passfail_class='success'
            passfail_text='PASS'
        else:
            passfail_class='important'
            passfail_text='FAIL'
        
        ot.append({ 'organisation_id': orgtest[0],
                    'organisation': dqorganisations.organisation_by_id(orgtest[0]),
                    'test_id': orgtest[1],
                    'test': dqtests.tests(orgtest[1]),
                    'success': round(pct, 2),
                    'total': totalsuccess+totalfail,
                    'results': orgtest_results,
                    'pass': passfail,
                    'passfail_text': passfail_text,
                    'passfail_class': passfail_class,
                    })
    return ot
Exemplo n.º 2
0
def get_org_info(organisation_id):
    return dqorganisations.organisation_by_id(organisation_id)