From a59d760e59abe58271b99a77cf3f56a1c1485362 Mon Sep 17 00:00:00 2001 From: Sami Mokaddem Date: Thu, 26 Oct 2017 09:12:50 +0200 Subject: [PATCH] Added datePicker in mips-geolocaloization --- server.py | 9 +++++---- templates/geo.html | 47 +++++++++++++++++++++++++++++++++++++++++----- 2 files changed, 47 insertions(+), 9 deletions(-) diff --git a/server.py b/server.py index d9bb175..341a88c 100755 --- a/server.py +++ b/server.py @@ -91,10 +91,11 @@ class EventMessage(): to_ret = { 'log': self.feed, 'feedName': self.feedName, 'zmqName': self.zmqName } return 'data: {}\n\n'.format(json.dumps(to_ret)) -def getZrange(keyCateg, wantedDate, topNum): +def getZrange(keyCateg, dayNum, topNum): aDateTime = datetime.datetime.now() + correctDatetime = aDateTime - datetime.timedelta(days = dayNum) - date_str = str(aDateTime.year)+str(aDateTime.month)+str(aDateTime.day) + date_str = str(correctDatetime.year)+str(correctDatetime.month)+str(correctDatetime.day) keyname = "{}:{}".format(keyCateg, date_str) data = serv_redis_db.zrange(keyname, 0, 5, desc=True, withscores=True) data = [ [record[0].decode('utf8'), record[1]] for record in data ] @@ -131,7 +132,7 @@ def getTopCoord(): try: dayNum = int(request.args.get('dayNum')) except: - dayNum = 1 + dayNum = 0 keyCateg = "GEO_COORD" topNum = 6 # default Num data = getZrange(keyCateg, dayNum, topNum) @@ -142,7 +143,7 @@ def getHitMap(): try: dayNum = int(request.args.get('dayNum')) except: - dayNum = 1 + dayNum = 0 keyCateg = "GEO_COUNTRY" topNum = -1 # default Num data = getZrange(keyCateg, dayNum, topNum) diff --git a/templates/geo.html b/templates/geo.html index d940938..48dc792 100644 --- a/templates/geo.html +++ b/templates/geo.html @@ -46,6 +46,7 @@ text-align: center; margin-left: 8px; float: left; + padding-top: 9px; } .center { @@ -69,7 +70,11 @@ small {