예제 #1
0
파일: views.py 프로젝트: mazhenpy/pylabsite
def access_count_day(req):
    day = time.strftime('%Y-%m-%d', time.localtime(time.time()))
    yesterday = str(datetime.date.today() - datetime.timedelta(days=1))
    #同步昨日的
    access_count = cache.get(yesterday, {'IP': 0, 'PV': 0})

    item = Access_amount_day()
    item.access_time = yesterday
    item.access_ip = access_count['IP']
    item.access_pv = access_count['PV']
    item.save()

    access_log.info("{0}访问量-IP:{1}-PV:{2}".format(yesterday,access_count['IP'],access_count['PV']))
    return HttpResponse("{0}访问量-IP:{1}-PV:{2}".format(yesterday,access_count['IP'],access_count['PV']))
예제 #2
0
def access_count_day(req):
    master_13 = RedisDriver().master_13
    day = time.strftime('%Y-%m-%d', time.localtime(time.time()))
    yesterday = str(datetime.date.today() - datetime.timedelta(days=1))
    # 同步昨日的
    yesd = 'Day:{0}'.format(yesterday)
    access_ip = master_13.hget(yesd, 'IP')
    access_pv = master_13.hget(yesd, 'PV')

    item = Access_amount_day()
    item.access_time = yesterday
    item.access_ip = access_ip
    item.access_pv = access_pv
    item.save()

    access_log.info("{0}访问量-IP:{1}-PV:{2}".format(yesterday, access_ip,
                                                  access_pv))
    return HttpResponse("{0}访问量-IP:{1}-PV:{2}".format(yesterday, access_ip,
                                                      access_pv))
예제 #3
0
def access_count_day(req):
    master_13 = RedisDriver().master_13
    day = time.strftime('%Y-%m-%d', time.localtime(time.time()))
    yesterday = str(datetime.date.today() - datetime.timedelta(days=1))
    # 同步昨日的
    yesd = 'Day:{0}'.format(yesterday)
    access_ip = master_13.hget(yesd, 'IP')
    access_pv = master_13.hget(yesd, 'PV')

    item = Access_amount_day()
    item.access_time = yesterday
    item.access_ip = access_ip
    item.access_pv = access_pv
    item.save()

    access_log.info("{0}访问量-IP:{1}-PV:{2}".format(yesterday, access_ip, access_pv))
    return HttpResponse("{0}访问量-IP:{1}-PV:{2}".format(yesterday, access_ip, access_pv))