fix: [UI-Hash] pie decoder

This commit is contained in:
Terrtia 2018-07-23 11:43:48 +02:00
parent 9c03c40482
commit 3479923f96
No known key found for this signature in database
GPG key ID: 1E1B1F50D84613D0
2 changed files with 20 additions and 6 deletions

View file

@ -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

View file

@ -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))