def get_last_five_tweets(self): if not self.last_five_tweets: return [] else: tweets = self.last_five_tweets.split(',') tweets = map(int, tweets) return twitter.get_tweets(tweets)
def get_followed_liked_tweets(self, max_tweets): tweets = [] if self.followed_users is not None: # TODO enforce followed_id uniqueness in the model followed_user_ids = set() for i in self.followed_users: followed_user_ids.add(i.followed_id) for i in followed_user_ids: followed_user = User.query.get(i) lt = followed_user.get_liked_tweet_ids() t = twitter.get_tweets(lt) tweets = (tweets + t) if len(tweets) >= max_tweets: return tweets[0:max_tweets] return tweets