Esempio n. 1
0
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)
Esempio n. 2
0
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}})
Esempio n. 3
0
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}})
Esempio n. 4
0
def get_recent_posts(limit=50):
    return posts.find().sort('created_time', pymongo.DESCENDING).limit(limit)
Esempio n. 5
0
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)
Esempio n. 6
0
def get_posts_ordered_by_popularity(the_page_id):
    return posts.find({
        'page_id': the_page_id
    }).sort('shares', pymongo.DESCENDING)
Esempio n. 7
0
def get_recent_posts(limit=50):
    return posts.find().sort('created_time', pymongo.DESCENDING).limit(limit)
Esempio n. 8
0
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)
Esempio n. 9
0
def get_posts_ordered_by_popularity(the_page_id):
    return posts.find({'page_id': the_page_id}).sort('shares', pymongo.DESCENDING)
Esempio n. 10
0
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)