def latest_activity(context, page=1): collection = mongodb.get_collection() object_list = collection.find().sort('lifestream:timestamp', pymongo.DESCENDING ).limit(PAGE_SIZE).skip((page-1)*PAGE_SIZE) to_return = { 'object_list': list(object_list), } return to_return
if len(more) < 1: break else: page += 1 if page > MAX_PAGES: break _save_tweets(tweets) #last_id = tweets[0]["id"] # # Private junk # import pymongo import lifestream.mongodb as mongodb collection = mongodb.get_collection() def _get_last_tweet_id(): tweets = collection.find({ "lifestream:source": u"twitter:user:%s" % settings.TWITTER_USERNAME} ).sort('id', pymongo.DESCENDING ) if tweets.count() > 0: return tweets[0]["id"] else: return 1 def _fetch_tweets(since_id=1, page=1): log.debug("Fetching tweets... since id: %s, page: %s", (str(since_id), str(page))) tweets = utils.getjson( USER_TIMELINE_URL % (page, since_id), username=settings.TWITTER_USERNAME,
def activity_list(request, page=1, template="lifestream/activity_list.html", **kwargs): collection = mongodb.get_collection() object_list = ( collection.find().sort("lifestream:timestamp", pymongo.DESCENDING).limit(PAGE_SIZE).skip((page - 1) * PAGE_SIZE) ) return render_to_response(template, {"object_list": list(object_list)}, context_instance=RequestContext(request))