def posts_from_date(date): d_end = date + datetime.timedelta(days=1) return posts.find({ 'created_time': { "$gt": date, "$lt": d_end } }).sort('shares', pymongo.DESCENDING)
def search_text_in_db(s): """ search text in db and return matched documents(posts) :return: return list of posts that match the text query. """ return posts.find({'$text': {'$search': s}})
def get_recent_posts(limit=50): return posts.find().sort('created_time', pymongo.DESCENDING).limit(limit)
def get_posts_ordered_by_score(the_page_id, limit=50): return posts.find({ 'page_id': the_page_id }).sort('shares', pymongo.DESCENDING).limit(limit)
def get_posts_ordered_by_popularity(the_page_id): return posts.find({ 'page_id': the_page_id }).sort('shares', pymongo.DESCENDING)
def get_posts_ordered_by_score(the_page_id, limit=50): return posts.find({'page_id': the_page_id}).sort('shares', pymongo.DESCENDING).limit(limit)
def get_posts_ordered_by_popularity(the_page_id): return posts.find({'page_id': the_page_id}).sort('shares', pymongo.DESCENDING)
def posts_from_date(date): d_end = date + datetime.timedelta(days=1) return posts.find({'created_time': {"$gt": date, "$lt": d_end}}).sort('shares', pymongo.DESCENDING)