def _split_tweets(self): tweet_days = {} for member in self._community_members: tweets = member['tweets'] for tweet in tweets: raw_timestamp = tweet['created_at'] formatted_timestamp = \ parse_twitter_timestamp(raw_timestamp) if formatted_timestamp in tweet_days: tweet_days[formatted_timestamp].append(tweet) else: tweet_days[formatted_timestamp] = [tweet] return tweet_days
def _active_tweeter(self, tweets): tweeted_today = False tweeted_yesterday = False for tweet in tweets: raw_timestamp = tweet['created_at'] formatted_timestamp = parse_twitter_timestamp(raw_timestamp) now = datetime.now() time_diff = now - formatted_timestamp if time_diff <= timedelta(days=1): tweeted_today = True if time_diff <= timedelta(days=2) and\ time_diff > timedelta(days=1): tweeted_yesterday = True return tweeted_today and tweeted_yesterday