Example #1
0
def day_report_job(now=None):
    '''day_report created at 23:58:00'''
    
    # 今天
    if not now:
        now = datetime.datetime.now()
    
    today_start = now.replace(hour=0, minute=0, second=0, microsecond=0)
    today_end = now.replace(hour=23, minute=59, second=59, microsecond=0)
    
    user = get_userdata_for_day_report(today_start, today_end);
    bookmark = get_bookmarkdata_for_day_report(today_start, today_end);
    
    bookmark_count = {}
    bookmark_count['percent'], bookmark_count['data'] = get_bookmark_percent_raw_data(today_start, today_end, limit=20)
    bookmark_website = {}
    bookmark_website['data'] = get_bookmark_website(today_start.strftime('%Y-%m-%d %H:%M:%S'), today_end.strftime('%Y-%m-%d %H:%M:%S'), limit=20)
    
    jsondata = {}
    jsondata['user'] = user
    jsondata['bookmark'] = bookmark
    jsondata['bookmark_website'] = bookmark_website
    jsondata['bookmark_count'] = bookmark_count
    
    day_report = Report(type='day', time=now, version=c.report_version, jsondata=anyjson.dumps(jsondata))
    day_report.save();
Example #2
0
def bookmark_website(request):
    start_time = request.GET.get('start_time', c.MIN_TIME)
    end_time = request.GET.get('end_time', c.MAX_TIME)
    limit = request.GET.get('size', '100')
    limit = int(limit if limit else 100)
    
    if start_time == 'NaN-aN-aN aN:aN:aN': 
        start_time = c.MIN_TIME
    if end_time == 'NaN-aN-aN aN:aN:aN': 
        end_time = c.MAX_TIME
    data = get_bookmark_website(start_time, end_time, limit=limit)
    jsondata = anyjson.dumps(data)
    
    response = HttpResponse(jsondata)
    # 缓存一天
    now = datetime.datetime.now()
    expire = now + datetime.timedelta(days=1)
    response['Expires'] = expire.strftime('%a, %d %b %Y 01:00:00 %Z')
    return response
Example #3
0
def bookmark_website(request):
    start_time = request.GET.get("start_time", c.MIN_TIME)
    end_time = request.GET.get("end_time", c.MAX_TIME)
    limit = request.GET.get("size", "100")
    limit = int(limit if limit else 100)

    if start_time == "NaN-aN-aN aN:aN:aN":
        start_time = c.MIN_TIME
    if end_time == "NaN-aN-aN aN:aN:aN":
        end_time = c.MAX_TIME
    data = get_bookmark_website(start_time, end_time, limit=limit)
    jsondata = anyjson.dumps(data)

    response = HttpResponse(jsondata)
    # 缓存一天
    now = datetime.datetime.now()
    expire = now + datetime.timedelta(days=1)
    response["Expires"] = expire.strftime("%a, %d %b %Y 01:00:00 %Z")
    return response