Пример #1
0
def aggregate_results_single_org(runtime, package_id, agg_type):
    status = "Updating"
    print "getting result ids"
    result_ids = get_results(runtime, package_id, agg_type)
    print "getting data"
    data = db.session.query(models.Test,
                models.Result.result_data,
                models.Result.result_hierarchy,
                func.count(models.Result.id),
                models.Result.package_id
        ).filter(models.Result.runtime_id==runtime
        ).filter(models.Result.package_id==package_id
        ).filter(models.Result.id.in_(result_ids)
        ).join(models.Result
        ).group_by(models.Result.package_id, 
                   models.Result.result_hierarchy, 
                   models.Test.id, 
                   models.Result.result_data
        ).all()

    print "got data, len:"
    print len(data)

    print "calc percentages"
    aresults = aggregations.aggregate_percentages(data)
    print "finished calculating percentages"

    for aresult in aresults:
        a = models.AggregateResult()
        a.runtime_id = runtime
        a.package_id = aresult["package_id"]
        a.test_id = aresult["test_id"]
        a.result_hierarchy = aresult["hierarchy"]
        a.results_data = aresult["percentage_passed"]
        a.results_num = aresult["total_results"]
        a.aggregateresulttype_id = agg_type.id
        db.session.add(a)
    
    return {"status": status, "data": aresults}
Пример #2
0
def aggregate_results_single_org(runtime, package_id, agg_type):
    status = "Updating"

    result_ids = get_results(runtime, package_id, agg_type)

    data = db.session.query(models.Test.id,
                models.Result.result_data,
                models.Result.result_hierarchy,
                func.count(models.Result.id),
                models.Result.package_id
        ).filter(models.Result.runtime_id==runtime
        ).filter(models.Result.package_id==package_id
        ).filter(models.Result.id.in_(result_ids)
        ).join(models.Result
        ).group_by(models.Result.package_id, 
                   models.Result.result_hierarchy, 
                   models.Test.id, 
                   models.Result.result_data
        ).all()

    aresults = aggregations.aggregate_percentages(data)

    with db.session.begin():
        delete_aggregations(db.session, package_id, agg_type)

        for aresult in aresults:
            a = models.AggregateResult()
            a.package_id = aresult["package_id"]
            a.test_id = aresult["test_id"]
            a.result_hierarchy = aresult["hierarchy"]
            a.results_data = aresult["percentage_passed"]
            a.results_num = aresult["total_results"]
            a.aggregateresulttype_id = agg_type.id
            db.session.add(a)
    
    return {"status": status, "data": aresults}