diff --git a/dashboard.py b/dashboard.py index 6fb5a52..1478963 100644 --- a/dashboard.py +++ b/dashboard.py @@ -13,7 +13,7 @@ root_content_path = 'dashboard_static' # the action will be called with the context and the event @event('init') def setup(ctx, e): - start_offline_tweets('sports1.txt', event_name="tweet", time_factor=0.1) + start_offline_tweets('sports1.txt', event_name="tweet", time_factor=0.01) ctx.count = 0 # fire('sample', {'previous': 0.0}) @@ -40,7 +40,58 @@ def words(message): @event('tweet') def generate_tweet(ctx, e): - tweet = e.data + tweet = dict(e.data) + try: + try: + tweet.pop("id_str") + except KeyError: + pass + try: + tweet.pop("display_text_range") + except KeyError: + pass + try: + tweet.pop("in_reply_to_status_id") + except KeyError: + pass + try: + tweet.pop("in_reply_to_status_id_str") + except KeyError: + pass + try: + tweet.pop("in_reply_to_user_id") + except KeyError: + pass + try: + tweet.pop("in_reply_to_user_id_str") + except KeyError: + pass + try: + tweet.pop("in_reply_to_screen_name") + except KeyError: + pass + try: + tweet.pop("geo") + except KeyError: + pass + try: + tweet.pop("coordinates") + except KeyError: + pass + try: + tweet.pop("place") + except KeyError: + pass + try: + tweet.pop("contributors") + except KeyError: + pass + try: + tweet.pop("is_quote_status") + except KeyError: + pass + except: + pass # base sample on previous one # sample = clip(-100, e.data['previous'] + random.uniform(+5.0, -5.0), 100) # emit to outside world diff --git a/dashboard_static/js/code.js b/dashboard_static/js/code.js index 8f97723..bf2dca8 100644 --- a/dashboard_static/js/code.js +++ b/dashboard_static/js/code.js @@ -24,18 +24,20 @@ function showFeeds() { } function tweetCell(tweet) { + const date = new Date(tweet.created_at); var cell = document.createElement("div"); cell.innerHTML = `
${tweet.created_at}
+ + ${date.getHours()}:${date.getMinutes()}