From b5a844dab83cca29d204bc40262e97831c9a3227 Mon Sep 17 00:00:00 2001 From: Sami Mokaddem Date: Fri, 17 Nov 2017 15:32:47 +0100 Subject: [PATCH] fix: do not json dumps string into redis (avoiding escaping) --- trendings_helper.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/trendings_helper.py b/trendings_helper.py index eba6f52..ceaa0a9 100644 --- a/trendings_helper.py +++ b/trendings_helper.py @@ -17,7 +17,11 @@ class Trendings_helper: timestampDate = datetime.datetime.fromtimestamp(float(timestamp)) timestampDate_str = util.getDateStrFormat(timestampDate) keyname = "{}:{}".format(trendingType, timestampDate_str) - self.serv_redis_db.zincrby(keyname, json.dumps(data), 1) + if isinstance(data, OrderedDict): + to_save = json.dumps(data) + else: + to_save = data + self.serv_redis_db.zincrby(keyname, to_save, 1) def addTrendingEvent(self, eventName, timestamp): self.addGenericTrending('TRENDINGS_EVENTS', eventName, timestamp)