From e56187eb7eac9a064004f06aeefeeb5e7526cd8d Mon Sep 17 00:00:00 2001 From: Mokaddem Date: Tue, 23 Aug 2016 14:52:02 +0200 Subject: [PATCH] Added position of each top term in the other sets + highligth ones not present. --- var/www/Flask_server.py | 13 +++++++++- var/www/templates/terms_plot_top.html | 36 ++++++++++++++++++--------- 2 files changed, 36 insertions(+), 13 deletions(-) diff --git a/var/www/Flask_server.py b/var/www/Flask_server.py index 07878927..45efd8f1 100755 --- a/var/www/Flask_server.py +++ b/var/www/Flask_server.py @@ -714,6 +714,10 @@ def terms_plot_top_data(): today = today.replace(hour=0, minute=0, second=0, microsecond=0) today_timestamp = calendar.timegm(today.timetuple()) + set_day = "TopTermFreq_set_day_" + str(today_timestamp) + set_week = "TopTermFreq_set_week"; + set_month = "TopTermFreq_set_month"; + the_set = request.args.get('set') num_day = int(request.args.get('num_day')) if the_set is None: @@ -724,13 +728,20 @@ def terms_plot_top_data(): the_set += "_" + str(today_timestamp) for term, tot_value in r_serv_term.zrevrangebyscore(the_set, '+inf', '-inf', withscores=True, start=0, num=20): + position = {} + position['day'] = r_serv_term.zrevrank(set_day, term) + position['day'] = position['day']+1 if position['day'] is not None else "<20" + position['week'] = r_serv_term.zrevrank(set_week, term) + position['week'] = position['week']+1 if position['week'] is not None else "<20" + position['month'] = r_serv_term.zrevrank(set_month, term) + position['month'] = position['month']+1 if position['month'] is not None else "<20" value_range = [] for timestamp in range(today_timestamp, today_timestamp - num_day*oneDay, -oneDay): value = r_serv_term.hget(timestamp, term) curr_value_range = int(value) if value is not None else 0 value_range.append([timestamp, curr_value_range]) - to_return.append([term, value_range, tot_value]) + to_return.append([term, value_range, tot_value, position]) return jsonify(to_return) diff --git a/var/www/templates/terms_plot_top.html b/var/www/templates/terms_plot_top.html index 42198391..ecfc5d22 100644 --- a/var/www/templates/terms_plot_top.html +++ b/var/www/templates/terms_plot_top.html @@ -26,6 +26,9 @@ padding-left:0; list-style:none } + .table > tbody > tr > td { + padding: 5px; + } @@ -82,7 +85,8 @@ Term Value Action - Displayed + Show + Position @@ -96,7 +100,8 @@ Term Value Action - Displayed + Show + Position @@ -148,7 +153,8 @@ Term Value Action - Displayed + Show + Position @@ -162,7 +168,8 @@ Term Value Action - Displayed + Show + Position @@ -214,7 +221,8 @@ Term Value Action - Displayed + Show + Position @@ -228,7 +236,8 @@ Term Value Action - Displayed + Show + Position @@ -336,6 +345,7 @@ promises.push($.getJSON("{{ url_for('terms_plot_top_data') }}", { set: set_today var to_plot = []; var unchecked_label = []; for(i=0; i"+data[i][0]+""+data[i][2]+""+addbuttons(data[i][0])+""+addcheckbox("today", data[i][0], i") + table_today.append(""+data[i][0]+""+data[i][2]+""+addbuttons(data[i][0])+""+addcheckbox("today", data[i][0], i"+data[i][3].week+", "+data[i][3].month+""); else - table_today2.append(""+data[i][0]+""+data[i][2]+""+addbuttons(data[i][0])+""+addcheckbox("today", data[i][0], i") + table_today2.append(""+data[i][0]+""+data[i][2]+""+addbuttons(data[i][0])+""+addcheckbox("today", data[i][0], i"+data[i][3].week+", "+data[i][3].month+""); } plot_today = $.plot($("#graph-today"), to_plot, graph_options); hide_unchecked_curves(plot_today, unchecked_label); @@ -375,6 +385,7 @@ promises.push($.getJSON("{{ url_for('terms_plot_top_data') }}", { set: set_week, var to_plot = []; var unchecked_label = []; for(i=0; i 20? " style=\"background-color: orange;\" " : ""; var curr_data = []; for(j=0; j"+data[i][0]+""+data[i][2]+""+addbuttons(data[i][0])+""+addcheckbox("week", data[i][0], i") + table.append(""+data[i][0]+""+data[i][2]+""+addbuttons(data[i][0])+""+addcheckbox("week", data[i][0], i"+data[i][3].day+", "+data[i][3].month+""); else - table2.append(""+data[i][0]+""+data[i][2]+""+addbuttons(data[i][0])+""+addcheckbox("week", data[i][0], i") + table2.append(""+data[i][0]+""+data[i][2]+""+addbuttons(data[i][0])+""+addcheckbox("week", data[i][0], i"+data[i][3].day+", "+data[i][3].month+""); } plot_week = $.plot($("#graph-week"), to_plot, graph_options); hide_unchecked_curves(plot_week, unchecked_label); @@ -413,6 +424,7 @@ promises.push($.getJSON("{{ url_for('terms_plot_top_data') }}", { set: set_month var to_plot = []; var unchecked_label = []; for(i=0; i 20? " style=\"background-color: orange;\" " : ""; var curr_data = []; for(j=0; j"+data[i][0]+""+data[i][2]+""+addbuttons(data[i][0])+""+addcheckbox("month", data[i][0], i") + table.append(""+data[i][0]+""+data[i][2]+""+addbuttons(data[i][0])+""+addcheckbox("month", data[i][0], i"+data[i][3].day+", "+data[i][3].week+""); else - table2.append(""+data[i][0]+""+data[i][2]+""+addbuttons(data[i][0])+""+addcheckbox("month", data[i][0], i") + table2.append(""+data[i][0]+""+data[i][2]+""+addbuttons(data[i][0])+""+addcheckbox("month", data[i][0], i"+data[i][3].day+", "+data[i][3].week+""); } plot_month = $.plot($("#graph-month"), to_plot, graph_options); hide_unchecked_curves(plot_month, unchecked_label);