From 3479923f96490f84370eb09c1a916074a337d77d Mon Sep 17 00:00:00 2001 From: Terrtia Date: Mon, 23 Jul 2018 11:43:48 +0200 Subject: [PATCH] fix: [UI-Hash] pie decoder --- .../modules/hashDecoded/Flask_hashDecoded.py | 21 +++++++++++++++---- .../hashDecoded/templates/hashDecoded.html | 5 +++-- 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/var/www/modules/hashDecoded/Flask_hashDecoded.py b/var/www/modules/hashDecoded/Flask_hashDecoded.py index 72d664d4..29f15275 100644 --- a/var/www/modules/hashDecoded/Flask_hashDecoded.py +++ b/var/www/modules/hashDecoded/Flask_hashDecoded.py @@ -350,10 +350,23 @@ def decoder_type_json(): date_from = request.args.get('date_from') date_to = request.args.get('date_to') - type = request.args.get('type') - encoding = request.args.get('encoding') + typ = request.args.get('type') + + if typ == 'All types': + typ = None + + # verify file type input + if typ is not None: + #retrieve + char + typ = typ.replace(' ', '+') + if typ not in r_serv_metadata.smembers('hash_all_type'): + typ = None all_decoder = r_serv_metadata.smembers('all_decoder') + # sort DESC decoder for color + all_decoder = sorted(all_decoder, reverse=True) + print(all_decoder) + print(type(all_decoder)) date_range = [] if date_from is not None and date_to is not None: @@ -372,10 +385,10 @@ def decoder_type_json(): nb_decoded = {} for date in date_range: for decoder in all_decoder: - if type is None: + if typ is None: nb_decoded[decoder] = r_serv_metadata.get(decoder+'_decoded:'+date) else: - nb_decoded[decoder] = r_serv_metadata.hget(decoder+'_type:'+type, date) + nb_decoded[decoder] = r_serv_metadata.zscore(decoder+'_type:'+typ, date) if nb_decoded[decoder] is None: nb_decoded[decoder] = 0 diff --git a/var/www/modules/hashDecoded/templates/hashDecoded.html b/var/www/modules/hashDecoded/templates/hashDecoded.html index 64c4b61c..6cffa9cc 100644 --- a/var/www/modules/hashDecoded/templates/hashDecoded.html +++ b/var/www/modules/hashDecoded/templates/hashDecoded.html @@ -525,11 +525,12 @@ var arc_pie = d3.arc() .innerRadius(0) .outerRadius(radius_pie); -d3.json("/hashDecoded/decoder_type_json?date_from={{date_from}}&date_to={{date_to}}") +d3.json("/hashDecoded/decoder_type_json?date_from={{date_from}}&date_to={{date_to}}&type={{type}}") .then(function(data){ var pie_pie = d3.pie() - .value(function(d) { return d.value; }); + .value(function(d) { return d.value; }) + .sort(null); var path_pie = g_pie.selectAll('path') .data(pie_pie(data))