def seed_tweets(self): '''Fetches 1 tweet (their most recent) per tracked user IF the user doesn't have any tweets in the DB already. returns: None ''' for user in self.tracked_users: if not user.tweets: tweet = fetch_most_recent_tweet(user.id) if tweet is not None: Tweet.create(tweet, user, needs_to_be_sent=False)
def get_recent_tweets(self): '''Fetches all recent tweets for all the tracked users and then inserts them into the DB. returns: None ''' for user in self.tracked_users: last_saved_tweet = Tweet.get_most_recent_by_user_id(user.id) # This is for certain users who have their twitter empty (EG: Mana Aloe). if last_saved_tweet is not None: new_tweets = fetch_new_tweets(user.id, last_saved_tweet.id) for tweet in new_tweets: if not Tweet.exists_by_id(tweet['id']): Tweet.create(tweet, user)