From cdd08d7df0921b5a7c773fcecba933d7fe6e8886 Mon Sep 17 00:00:00 2001 From: Mokaddem Date: Tue, 16 Aug 2016 11:07:36 +0200 Subject: [PATCH] Added all providers for plot_tool in moduleStats + fixed date range bug --- bin/ModuleStats.py | 2 ++ var/www/Flask_server.py | 9 ++++----- var/www/static/js/sentiment_plot.js | 1 + 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/bin/ModuleStats.py b/bin/ModuleStats.py index d5849951..10da3f7c 100755 --- a/bin/ModuleStats.py +++ b/bin/ModuleStats.py @@ -72,6 +72,7 @@ def compute_most_posted(server, message): def compute_provider_info(server, path): + redis_all_provider = 'all_provider_set' redis_avg_size_name_set = 'top_size_set' redis_providers_name_set = 'providers_set' @@ -83,6 +84,7 @@ def compute_provider_info(server, path): new_avg = paste_size # Add/Update in Redis + server.sadd(redis_all_provider, paste_provider) prev_num_paste = server.hget(paste_provider+'_num', paste_date) if prev_num_paste is not None: ok = server.hset(paste_provider+'_num', paste_date, int(prev_num_paste)+1) diff --git a/var/www/Flask_server.py b/var/www/Flask_server.py index 6820bf66..1ff8b097 100755 --- a/var/www/Flask_server.py +++ b/var/www/Flask_server.py @@ -480,7 +480,7 @@ def sentiment_analysis_plot_tool_getdata(): if getProviders == 'True': providers = [] - for cur_provider in r_serv_charts.smembers('providers_set'): + for cur_provider in r_serv_charts.smembers('all_provider_set'): providers.append(cur_provider) return jsonify(providers) @@ -488,8 +488,6 @@ def sentiment_analysis_plot_tool_getdata(): query = request.args.get('query') query = query.split(',') Qdate = request.args.get('Qdate') - print query - print Qdate date1 = (Qdate.split('-')[0]).split('.') date1 = datetime.date(int(date1[2]), int(date1[1]), int(date1[0])) @@ -499,14 +497,15 @@ def sentiment_analysis_plot_tool_getdata(): timestamp1 = calendar.timegm(date1.timetuple()) timestamp2 = calendar.timegm(date2.timetuple()) + print timestamp2 oneHour = 60*60 - print timestamp1, timestamp2 + oneDay = oneHour*24 to_return = {} for cur_provider in query: list_date = {} cur_provider_name = cur_provider + '_' - for cur_timestamp in range(int(timestamp1), int(timestamp2), oneHour): + for cur_timestamp in range(int(timestamp1), int(timestamp2)+oneDay, oneHour): cur_set_name = cur_provider_name + str(cur_timestamp) list_value = [] diff --git a/var/www/static/js/sentiment_plot.js b/var/www/static/js/sentiment_plot.js index b8541247..2b1ab230 100644 --- a/var/www/static/js/sentiment_plot.js +++ b/var/www/static/js/sentiment_plot.js @@ -65,6 +65,7 @@ function plotData(){ // retreive the data from the server $.getJSON('/sentiment_analysis_plot_tool_getdata/?getProviders=False&query='+query+'&Qdate='+Qdate, function(data){ + console.log(data); var to_plot = []; for (provider in data){ var nltk_data = Object.keys(data[provider]).map(function (key) { return data[provider][key]; });