From 2466f355ab2dd54bb10964b8e3684a318ecc42b9 Mon Sep 17 00:00:00 2001 From: Mokaddem Date: Mon, 22 Aug 2016 14:54:37 +0200 Subject: [PATCH] Fixed bug in manage-terms-top-set + added auto sorting in important-paste-by-module --- bin/Curve.py | 2 +- bin/Curve_manage_top_sets.py | 12 +++++++++--- var/www/templates/important_paste_by_module.html | 2 +- var/www/templates/terms_plot_top.html | 2 -- 4 files changed, 11 insertions(+), 7 deletions(-) diff --git a/bin/Curve.py b/bin/Curve.py index b43fcb1d..641480eb 100755 --- a/bin/Curve.py +++ b/bin/Curve.py @@ -113,7 +113,7 @@ if __name__ == "__main__": temp = filename.split('/') date = temp[-4] + temp[-3] + temp[-2] timestamp = calendar.timegm((int(temp[-4]), int(temp[-3]), int(temp[-2]), 0, 0, 0)) - top_termFreq_setName_day[0] += timestamp + top_termFreq_setName_day[0] += str(timestamp) low_word = word.lower() diff --git a/bin/Curve_manage_top_sets.py b/bin/Curve_manage_top_sets.py index c3494c16..167aa261 100755 --- a/bin/Curve_manage_top_sets.py +++ b/bin/Curve_manage_top_sets.py @@ -50,10 +50,12 @@ def manage_top_set(): dico = {} # Retreive top data (2*max_card) from days sets - for timestamp in range(startDate, startDate - num_day_month*oneDay, -oneDay): - top_termFreq_setName_day[0] += str(timestamp) - array_top_day = server_term.zrangebyscore(top_termFreq_setName_day[0], '-inf', '+inf', withscores=True, start=0, num=top_term_freq_max_set_cardinality*2) + for timestamp in range(startDate, startDate - top_termFreq_setName_month[1]*oneDay, -oneDay): + curr_set = top_termFreq_setName_day[0] + str(timestamp) + print top_termFreq_setName_day[0] + array_top_day = server_term.zrangebyscore(curr_set, '-inf', '+inf', withscores=True, start=0, num=top_term_freq_max_set_cardinality*2) + print array_top_day for word, value in array_top_day: if word in dico.keys(): dico[word] += value @@ -68,12 +70,16 @@ def manage_top_set(): for w, v in dico.iteritems(): array_month.append((w, v)) array_month.sort(key=lambda tup: -tup[1]) + array_month = array_month[0:20] array_week = [] for w, v in dico_week.iteritems(): array_week.append((w, v)) array_week.sort(key=lambda tup: -tup[1]) + array_week = array_week[0:20] + print array_month + print array_week # suppress every terms in top sets for curr_set, curr_num_day in top_termFreq_set_array[1:3]: diff --git a/var/www/templates/important_paste_by_module.html b/var/www/templates/important_paste_by_module.html index 164ed800..fdb732ba 100644 --- a/var/www/templates/important_paste_by_module.html +++ b/var/www/templates/important_paste_by_module.html @@ -28,7 +28,7 @@ diff --git a/var/www/templates/terms_plot_top.html b/var/www/templates/terms_plot_top.html index da5b9b2f..da3611bf 100644 --- a/var/www/templates/terms_plot_top.html +++ b/var/www/templates/terms_plot_top.html @@ -463,11 +463,9 @@ function hide_or_show() { var curr_term = $(this).attr('data-term'); var graph = $(this).attr('data-graph'); var checked = $(this).prop('checked') - console.log(curr_term + ' ' + graph + ' ' + checked); if(graph == "today") { var graphData = plot_today.getData(); - console.log(graphData); var index; for(i=0; i