예제 #1
0
def stat(request,source='',detail='',dur=''):
    if source:
        qd.sources = [source]
    if detail:
        qd.detail = detail
    if dur:
        qd.day_dt_stat_date = time.strftime('%Y-%m-%d',time.localtime(time.time()-86400*int(dur)))
        
    dic = qd.getDetail()
    dateList = qd.getDates(qd.day_dt_stat_date,qd.day_dt_end_date)
    for source in dic:
        for detail in dic[source]:
            for dt in dateList:
                if dt not in dic[source][detail]:
                    dic[source][detail][dt] = {'uv':0,'pv':0}
    datas = {}
    for source in dic:
        for detail in dic[source]:
            if detail not in ['avg','total']:
                datas[detail] = []
                for dt in dateList:
                    datas[detail].append(dic[source][detail][dt]['uv'])
                    
    return render_to_response('lineChart.html', {'dateList': dateList, 'datas':datas} )
예제 #2
0
import qd
dic = qd.getDetail()
dateList = qd.getDates(qd.day_dt_stat_date,qd.day_dt_end_date)
for source in dic:
    for detail in dic[source]:
        for dt in dateList:
            if dt not in dic[source][detail]:
                dic[source][detail][dt] = {'uv':0,'pv':0}

print dic

datas = {}
for source in dic:
    for detail in dic[source]:
        if detail not in ['avg','total']:
            datas[detail] = ''
            for dt in dateList:
                datas[detail] = str(datas[detail]) + ',' + str(dic[source][detail][dt]['uv'])
            datas[detail] = datas[detail].split(',')[1]
print datas