Пример #1
0
def build_result(product,
                 rhic,
                 start,
                 end,
                 contract_number,
                 count,
                 environment,
                 product_config,
                 compliant):
    result_dict = {}
    hours_for_sub = get_datespan(start, end, product_config)
    nau = subscription_calc(count, start, end, product_config)
    
    result_dict['count'] = count
    result_dict['compliant'] = compliant
    result_dict['nau'] = "{0:.0f}".format(nau)
    result_dict['rhic'] = str(rhic.name)
    result_dict['product_name'] = product.name
    result_dict['engineering_id'] = str(product.engineering_ids)
    result_dict['contract_use'] = product.quantity
    result_dict['sla'] = product.sla
    result_dict['support'] = product.support_level
    result_dict['contract_id'] = contract_number
    result_dict['start'] = get_date_epoch(start)
    result_dict['end'] = get_date_epoch(end)
    result_dict['sub_hours'] = hours_for_sub
    result_dict['product_config'] = json.dumps(product_config)
    
    return result_dict
Пример #2
0
def detailed_report(request):
    data = utils.data_from_post(request)
    
    filter_args_dict = data['filter_args_dict']
    date = datetime.strptime(data['date'], constants.just_date)
    day = date.strftime(constants.day_fmt)

    results = []
    instances = ReportData.objects.filter(day=day, **filter_args_dict).distinct('instance_identifier')
    for i in instances:
        count = ReportData.objects.filter(instance_identifier=i, day=day, **filter_args_dict).count()
        results.append({'instance': i, 'count': count})

    

    response_data = {}
    response_data['list'] = results
    response_data['date'] = get_date_epoch(date)
    response_data['this_filter'] = filter_args_dict
    response_data['description'] = data['description']

    return create_response(response_data)