示例#1
0
def old_counts():
    results = store.get_db()[STREAM_NAME].map_reduce(MAP_FN, REDUCE_FN, 'xyz')
    tag_2_count = [(r['_id'], int(r['value']))
                   for r in results.find()]
    dico = dict(tag_2_count)
    v = val_or_0
    new_dico = {}
    for t in HASHTAGS:
        new_dico['#' + t] = v(dico, t.lower())
    return new_dico
示例#2
0
文件: photos.py 项目: marklar/massiu
def get_imgs_from_tweets(stream_name, hashtag=None):
    store.drop_coll(stream_name)
    gather.only_new_tweets(stream_name)
    query = {'entities.media.media_url': {'$exists': True}}
    if hashtag is not None:
        hashtag_re = hashtags.make_re(hashtag)
        query['entities.hashtags.text'] = hashtag_re
    coll = store.get_db()[stream_name]
    pics = [get_pic(t)
            for t in coll.find(query).sort('id_str', pymongo.DESCENDING)]
    return [p for p in pics if not None]
示例#3
0
def get_coll():
    return store.get_db()[MSG_COLL]