aboutsummaryrefslogtreecommitdiff
path: root/bh20simplewebuploader
diff options
context:
space:
mode:
authorPjotr Prins2020-12-19 11:05:19 +0000
committerGitHub2020-12-19 11:05:19 +0000
commit73e0e802dd254bf2d167f6633c479e90b9bc4649 (patch)
tree433e1ea607a70880c92854404cae320bcdf29be7 /bh20simplewebuploader
parent6814f9d74ca1d7fe4a7a08e5df0878557bd8e8f1 (diff)
parent35b1eb80cc8d0fb880c949de806c0ddba23c0fd9 (diff)
downloadbh20-seq-resource-73e0e802dd254bf2d167f6633c479e90b9bc4649.tar.gz
bh20-seq-resource-73e0e802dd254bf2d167f6633c479e90b9bc4649.tar.lz
bh20-seq-resource-73e0e802dd254bf2d167f6633c479e90b9bc4649.zip
Merge pull request #118 from BonfaceKilz/Chore/Display-10-tweets-in-feed
Display only 10 tweets on the feed
Diffstat (limited to 'bh20simplewebuploader')
-rw-r--r--bh20simplewebuploader/main.py14
1 files changed, 9 insertions, 5 deletions
diff --git a/bh20simplewebuploader/main.py b/bh20simplewebuploader/main.py
index d6e5249..d697918 100644
--- a/bh20simplewebuploader/main.py
+++ b/bh20simplewebuploader/main.py
@@ -259,11 +259,15 @@ def send_home():
tweets = []
try:
for tweet_id in redis_client.zrevrange('bh20-tweet-score:',
- 0, -1):
- tweets.append(
- {k.decode("utf-8"): v.decode("utf-8") for k, v in
- redis_client.hgetall(tweet_id).items()}
- )
+ 0, 9):
+ # Ensure the dict always has a value; otherwise a key
+ # error will be thrown by jinja
+ tweet_dict = redis_client.hgetall(tweet_id)
+ if tweet_dict:
+ tweets.append(
+ {k.decode("utf-8"): v.decode("utf-8") for k, v in
+ tweet_dict.items()})
+
except redis.exceptions.ConnectionError as e:
logging.warning(f"redis connect failed {e}")
pass