Example #1
0
def start_user_tagging():
    """
    根据所有未标注过的交互记录,对用户进行tagging
    :return:
    """
    try:
        reaction_list = DAO_utils.mongo_get_reactions()
        reaction_type_weight = DAO_utils.mongo_get_reaction_type_weight()
        a_u_map = DAO_utils.mongo_get_a_u_tagmap()
        count = tagging_utils.user_tagging_by_reactionlist(reaction_list, reaction_type_weight, a_u_map)
        return json.dumps({'code': 0, 'msg': 'handled %s reactions' % count})
    except Exception, e:
        return json.dumps({'code': 1, 'msg': 'unknown error, details = %s' % str(e)})
Example #2
0
def tagging_by_url():
    try:
        req_data = json.loads(request.data)
        user_id = req_data['user_id']
        admin_id = req_data['admin_id']
        article_url = req_data['article_url']
        reaction_type_weight = DAO_utils.mongo_get_reaction_type_weight()

        result = tagging_utils.user_tagging_by_url(article_url=article_url, admin_id=admin_id, user_id=user_id,
                                                   reaction_type_weight=reaction_type_weight)
        resp = make_response(json.dumps(result), 200)
    except Exception, e:
        print e
        resp = make_response(json.dumps({'code': 1, 'msg': 'unknown error, details = %s' % str(e)}), 400)