def get_votes_for_user(username):
'''
Get all the votes that this user has cast on articles
'''
log(0, 'Getting votes for user {}'.format(username))
req_data = bson.BSON.encode({
"key": key,
"database": "feedlark",
"collection": "vote",
"query": {
"username": username
},
"projection": {}
})
get_response = gearman_client.submit_job('db-get', str(req_data))
result = bson.BSON(get_response.result).decode()
if result['status'] != 'ok':
log(2, "Error getting votes for user {}".format(username))
log(2, result['description'])
return None
if 'docs' not in result or len(result['docs']) == 0:
log(1, "No docs returned for user {}".format(username))
return []
return result['docs']
评论列表
文章目录