Beispiel #1
0
def stats():
    db_file = g.db_file
    top_items = top_things(db_file)
    graph_data = top_items[2]

    last_day = get_items_last_X_days(db_file, 1, munge=False)
    ten_days = get_items_last_X_days(g.db_file, 10)
    hourly_activity = aggregate_by_hour(db_file)

    time = datetime.now() - timedelta(days=10)
    date_obj = date(year=time.year, month=time.month, day=time.day)
    day_unix = int(mktime(date_obj.timetuple()))

    p_to_dp_ten = {}
    stats_ten = []

    for item in ten_days:
        for person in ten_days[item]:
            if p_to_dp_ten.get(person, False) == False:
                p_to_dp_ten[person] = [[item, ten_days[item][person]]]
            else:
                p_to_dp_ten[person].append([item, ten_days[item][person]])

    for item in p_to_dp_ten:
        stats_ten.append({"name": item, "data": sorted(p_to_dp_ten[item])})

    p_to_dp = {}
    stats = []
    people = {}
    i = 0

    for item in last_day:
        for person in last_day[item]:
            if people.get(person, False) == False:
                people[person] = i
                i = i+1
            if p_to_dp.get(person, False) == False:
                p_to_dp[person] = [[item, last_day[item][person]]]
            else:
                p_to_dp[person].append([item, last_day[item][person]])

    for item in p_to_dp:
        def muh_lambda(x):
            return (x[0], people[item])
        stats.append({"name": item, "data": map(muh_lambda, sorted(p_to_dp[item]))})

    return render_template("stats.html",
        items=top_items,
        hourly_activity=hourly_activity,
        start_date=day_unix,
        stats=stats,
        stats_ten=stats_ten,
        graph_data=graph_data)
Beispiel #2
0
def sigma():
    items = top_things(g.db_file)
    graph_data = items[2]
    return render_template("sigma.html", items=items, graph_data=graph_data)