From 4071bf2e9116a0b35334037881a29db269c2ade1 Mon Sep 17 00:00:00 2001 From: Mokaddem Date: Tue, 28 Feb 2017 15:01:48 +0100 Subject: [PATCH] fixed a bug in manage_term (usage of loop.index0) + fixed bug in top_set where graph was not displaying the correct per_paste value --- bin/Curve.py | 4 ++-- bin/CurveManageTopSets.py | 2 +- var/www/Flasks/Flask_terms.py | 21 +++++++++++++-------- var/www/templates/terms_management.html | 24 ++++++++++-------------- var/www/templates/terms_plot_top.html | 12 +++++++++--- 5 files changed, 35 insertions(+), 28 deletions(-) diff --git a/bin/Curve.py b/bin/Curve.py index 61afc81a..e6c0bb05 100755 --- a/bin/Curve.py +++ b/bin/Curve.py @@ -120,14 +120,14 @@ if __name__ == "__main__": #consider the num of occurence of this term curr_word_value = int(server_term.hincrby(timestamp, low_word, int(score))) #1 term per paste - curr_word_value_perPaste = int(server_term.hincrby(timestamp, low_word, int(1))) + curr_word_value_perPaste = int(server_term.hincrby("per_paste_" + str(timestamp), low_word, int(1))) # Add in set only if term is not in the blacklist if low_word not in server_term.smembers(BlackListTermsSet_Name): #consider the num of occurence of this term server_term.zincrby(curr_set, low_word, float(score)) #1 term per paste - server_term.zincrby("per_paste_" + curr_set, low_word, float(score)) + server_term.zincrby("per_paste_" + curr_set, low_word, float(1)) #Add more info for tracked terms check_if_tracked_term(low_word, filename) diff --git a/bin/CurveManageTopSets.py b/bin/CurveManageTopSets.py index 8fd5b9bf..562705cf 100755 --- a/bin/CurveManageTopSets.py +++ b/bin/CurveManageTopSets.py @@ -63,7 +63,7 @@ def manage_top_set(): else: dico[word] = value - for word, value in "per_paste_" + array_top_day: + for word, value in array_top_day_per_paste: if word not in server_term.smembers(BlackListTermsSet_Name): if word in dico_per_paste.keys(): dico_per_paste[word] += value diff --git a/var/www/Flasks/Flask_terms.py b/var/www/Flasks/Flask_terms.py index 3ccf525d..b56375e7 100644 --- a/var/www/Flasks/Flask_terms.py +++ b/var/www/Flasks/Flask_terms.py @@ -208,16 +208,21 @@ 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')) per_paste = int(request.args.get('per_paste')) if per_paste == 1: - the_set = "per_paste_" + the_set + per_paste = "per_paste_" + else: + per_paste = "" + set_day = per_paste + "TopTermFreq_set_day_" + str(today_timestamp) + set_week = per_paste + "TopTermFreq_set_week"; + set_month = per_paste + "TopTermFreq_set_month"; + + the_set = per_paste + request.args.get('set') + num_day = int(request.args.get('num_day')) + + print(set_day) + print(per_paste) if the_set is None: return "None" else: @@ -235,7 +240,7 @@ def terms_plot_top_data(): 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) + value = r_serv_term.hget(per_paste+str(timestamp), term) curr_value_range = int(value) if value is not None else 0 value_range.append([timestamp, curr_value_range]) diff --git a/var/www/templates/terms_management.html b/var/www/templates/terms_management.html index 3d4f2f77..1cbfb67c 100644 --- a/var/www/templates/terms_management.html +++ b/var/www/templates/terms_management.html @@ -116,21 +116,19 @@ - {% set i = 0 %} {% for term in track_list %} {{ term }} - {{ track_list_values[i][3] }} - {{ track_list_values[i][0] }} - {{ track_list_values[i][1] }} - {{ track_list_values[i][2] }} - {{ track_list_num_of_paste[i] }} + {{ track_list_values[loop.index0][3] }} + {{ track_list_values[loop.index0][0] }} + {{ track_list_values[loop.index0][1] }} + {{ track_list_values[loop.index0][2] }} + {{ track_list_num_of_paste[loop.index0] }}

- {% set i = i + 1 %} {% endfor %} @@ -162,22 +160,20 @@ - + - {% set i = 0 %} - {% for term in black_list %} + {% for term, date in black_list %} - - + + - {% set i = i + 1 %} {% endfor %}
TermxTerm Added date Action
{{ black_list[i][0] }}{{ black_list[i][1] }}{{ term }}{{ date }}

- +

diff --git a/var/www/templates/terms_plot_top.html b/var/www/templates/terms_plot_top.html index af62c33f..77caa0fe 100644 --- a/var/www/templates/terms_plot_top.html +++ b/var/www/templates/terms_plot_top.html @@ -12,6 +12,7 @@ + @@ -67,9 +68,14 @@
-
- 1 term per paste -
+
+ + 1 term per paste +
Today