示例#1
0
def topic():
    if "logged_in" in session and session["logged_in"]:
        if session["user"] == "admin":
            request_method = request.method

            if request_method == "GET":
                args = request.args
                topic = args.get("keyword", None)
                time = args.get("time", None)
                rank_method = args.get("rank_method", "pagerank")
                page_num = args.get("page_num", 20)
                top_n = args.get("top_n", 500)

                if not topic or not time:
                    return redirect("/identify/")

                dur_time = _utf_encode(time)
                start_ts, end_ts = _time_zone(dur_time)

                return render_template(
                    "identify/topic.html",
                    topic=topic,
                    start_ts=start_ts,
                    end_ts=end_ts,
                    rank_method=rank_method,
                    page_num=page_num,
                    top_n=top_n,
                    window_size=1,
                    dur_time=_utf_decode(dur_time),
                )

            if request_method == "POST":
                form = request.form
                topic = form.get("topic", None)
                start_ts = form.get("start_ts", None)
                end_ts = form.get("end_ts", None)
                if start_ts:
                    start_ts = int(start_ts)
                if end_ts:
                    end_ts = int(end_ts)
                rank_method = form.get("rank_method", "pagerank")
                page_num = int(form.get("page_num", 20))
                top_n = int(form.get("top_n", 500))

                current_date = ts2datetime(end_ts)
                window_size = (end_ts - start_ts) / (24 * 3600)
                data = read_topic_rank_results(topic, top_n, rank_method, current_date, window_size)

                return json.dumps({"status": "current finished", "data": data})
    else:
        return redirect("/")
示例#2
0
文件: views.py 项目: huxiaoqian/case
def network_rank():
    topic = request.args.get('topic', '')
    start_ts = request.args.get('start_ts', '')
    start_ts = int(start_ts)
    end_ts = request.args.get('end_ts', '')
    end_ts = int(end_ts)
    windowsize = (end_ts - start_ts) / Day
    topn = request.args.get('topn', 100)
    topn = int(topn)
    domain = request.args.get('domain', 'all')
    date = ts2datetime(end_ts)
    rank_method = 'spark_pagerank'
    results = read_topic_rank_results(topic, topn, rank_method, date, windowsize, domain)
    return json.dumps(results)
示例#3
0
文件: views.py 项目: NeilWang6/case
def network_rank():
    topic = request.args.get('topic', '')
    start_ts = request.args.get('start_ts', '')
    start_ts = int(start_ts)
    end_ts = request.args.get('end_ts', '')
    end_ts = int(end_ts)
    windowsize = (end_ts - start_ts) / Day
    topn = request.args.get('topn', 100)
    topn = int(topn)
    domain = request.args.get('domain', 'all')
    date = ts2datetime(end_ts)
    rank_method = 'spark_pagerank'
    results = read_topic_rank_results(topic, topn, rank_method, date,
                                      windowsize, domain)
    return json.dumps(results)