Example #1
0
def traffic_query(request):
    '''
    流量查请求
    '''
    node_id = request.POST.get('node_id', 0)
    node_name = request.POST.get('node_name', '')
    user_id = request.user.ss_user.user_id
    last_week = get_date_list(7)
    labels = ['{}-{}'.format(t.month, t.day) for t in last_week]
    trafficdata = [TrafficLog.getTrafficByDay(
        node_id, user_id, t) for t in last_week]
    title = '节点 {} 当月共消耗:{} GB'.format(
        node_name, TrafficLog.getUserTraffic(node_id, user_id))
    configs = {
        'title': title,
        'labels': labels,
        'data': trafficdata,
        'data_title': node_name,
        'x_label': '日期 最近七天',
        'y_label': '流量 单位:GB'
    }
    return JsonResponse(configs)
Example #2
0
def traffic_query(request):
    '''
    流量查请求
    '''
    node_id = request.POST.get('node_id', 0)
    node_name = request.POST.get('node_name', '')
    user_id = request.user.ss_user.user_id
    last_week = get_date_list(7)
    labels = ['{}-{}'.format(t.month, t.day) for t in last_week]
    trafficdata = [
        TrafficLog.getTrafficByDay(node_id, user_id, t) for t in last_week
    ]
    title = '节点 {} 当月共消耗:{} GB'.format(
        node_name, TrafficLog.getUserTraffic(node_id, user_id))
    configs = {
        'title': title,
        'labels': labels,
        'data': trafficdata,
        'data_title': node_name,
        'x_label': '日期 最近七天',
        'y_label': '流量 单位:GB'
    }
    return JsonResponse(configs)