def add_topic_view_counts(self, posts): """ Adds view counts for the Topics of the given Posts. """ for post, view_count in izip( posts, redis.get_view_counts([p.topic_id for p in posts])): post.topic_view_count = view_count return posts
def add_topic_view_counts(self, posts): """ Adds view counts for the Topics of the given Posts. """ for post, view_count in izip(posts, redis.get_view_counts([p.topic_id for p in posts])): post.topic_view_count = view_count return posts
def add_view_counts(self, topics): """ Adds view counts to the given Topics. """ for topic, view_count in izip( topics, redis.get_view_counts([t.pk for t in topics])): topic.view_count = view_count return topics
def add_view_counts(self, topics): """ Adds view counts to the given Topics. """ for topic, view_count in izip(topics, redis.get_view_counts([t.pk for t in topics])): topic.view_count = view_count return topics