Esempio n. 1
0
def statusboard_videos():
    """Return video data formatted for http://panic.com/statusboard/"""
    results = sorted(data.video_title_summary(db, "Total", "day", None, None),
                     key=operator.itemgetter("dt"),
                     reverse=True)
    videos = []
    for result in results[:28]:
        videos.append({
            "title": result["dt"],
            "value": int(result["hours_all"] * 60)
        })
    videos.reverse()
    return flask.jsonify({
        "graph": {
            "title":
            "Videos",
            "type":
            "bar",
            "total":
            True,
            "datasequences": [{
                "title": "Minutes viewed per day",
                "color": "blue",
                "datapoints": videos
            }]
        }
    })
Esempio n. 2
0
def video_title_summary_data():
    start_dt = flask.request.args.get('start_date', '')
    end_dt = flask.request.args.get('end_date', '')
    title = flask.request.args.get('title', 'Total')
    duration = flask.request.args.get('time_scale', 'month')
    results = data.video_title_summary(db, title, duration, start_dt, end_dt)
    return flask.jsonify({'results': results})
Esempio n. 3
0
def statusboard_videos():
    """Return video data formatted for http://panic.com/statusboard/"""
    results = sorted(
                data.video_title_summary(db, "Total", "day", None, None),
                key=operator.itemgetter("dt"),
                reverse=True)
    videos = []
    for result in results[:28]:
        videos.append({
            "title": result["dt"],
            "value": int(result["hours_all"] * 60)
        })
    videos.reverse()
    return flask.jsonify({
        "graph": {
            "title": "Videos",
            "type": "bar",
            "total": True,
            "datasequences": [
                {
                    "title": "Minutes viewed per day",
                    "color": "blue",
                    "datapoints": videos
                }
            ]
        }
    })
Esempio n. 4
0
def video_title_summary_data():
    start_dt = flask.request.args.get('start_date', '')
    end_dt = flask.request.args.get('end_date', '')
    title = flask.request.args.get('title', 'Total')
    duration = flask.request.args.get('time_scale', 'month')
    results = data.video_title_summary(db, title, duration, start_dt, end_dt)
    return flask.jsonify({'results': results})
Esempio n. 5
0
def video_title_summary_data():
    start_dt = flask.request.args.get("start_date", "")
    end_dt = flask.request.args.get("end_date", "")
    title = flask.request.args.get("title", "Total")
    duration = flask.request.args.get("time_scale", "month")
    results = data.video_title_summary(db, title, duration, start_dt, end_dt)
    return flask.jsonify({"results": results})
Esempio n. 6
0
def statusboard_videos_today_value():
    """Return data for the video widget for http://panic.com/statusboard/"""
    start_dt = datetime.date.today() - datetime.timedelta(days=7)
    end_dt = start_dt + datetime.timedelta(days=1)
    start_dt_str = start_dt.strftime("%Y-%m-%d")
    end_dt_str = end_dt.strftime("%Y-%m-%d")
    summary = data.video_title_summary(db, "Total", "day", start_dt_str,
                                       end_dt_str)
    if len(summary) == 0:
        # TODO(dylan): Do something better than fudging the value
        value = 20000 * 60
    else:
        value = summary[0]["hours_all"] * 60
    return flask.jsonify({"value": value})
Esempio n. 7
0
def statusboard_videos_today_value():
    """Return data for the video widget for http://panic.com/statusboard/"""
    start_dt = datetime.date.today() - datetime.timedelta(days=7)
    end_dt = start_dt + datetime.timedelta(days=1)
    start_dt_str = start_dt.strftime("%Y-%m-%d")
    end_dt_str = end_dt.strftime("%Y-%m-%d")
    summary = data.video_title_summary(
        db, "Total", "day", start_dt_str, end_dt_str)
    if len(summary) == 0:
        # TODO(dylan): Do something better than fudging the value
        value = 20000 * 60
    else:
        value = summary[0]["hours_all"] * 60
    return flask.jsonify({"value": value})