示例#1
0
文件: worker.py 项目: fchasen/h
def remove_nipsa(userid):
    log.info("clearing nipsa flag for user annotations: %s", userid)

    if celery.request.feature('postgres'):
        bulk_update_annotations(celery.request.es,
                                search.nipsad_annotations(userid),
                                remove_nipsa_action)

    bulk_update_annotations(celery.request.legacy_es,
                            search.nipsad_annotations(userid),
                            remove_nipsa_action)
示例#2
0
def add_or_remove_nipsa(client, index, userid, action):
    """Add/remove the NIPSA flag to/from all of the user's annotations."""
    assert action in ("add_nipsa", "remove_nipsa")
    if action == "add_nipsa":
        query = search.not_nipsad_annotations(userid)
        action_func = add_nipsa_action
    else:
        query = search.nipsad_annotations(userid)
        action_func = remove_nipsa_action

    annotations = helpers.scan(client=client, query=query)
    actions = [action_func(index, a) for a in annotations]
    helpers.bulk(client=client, actions=actions)
示例#3
0
def add_or_remove_nipsa(client, index, userid, action):
    """Add/remove the NIPSA flag to/from all of the user's annotations."""
    assert action in ("add_nipsa", "remove_nipsa")
    if action == "add_nipsa":
        query = search.not_nipsad_annotations(userid)
        action_func = add_nipsa_action
    else:
        query = search.nipsad_annotations(userid)
        action_func = remove_nipsa_action

    annotations = helpers.scan(client=client, query=query)
    actions = [action_func(index, a) for a in annotations]
    helpers.bulk(client=client, actions=actions)
示例#4
0
def test_nipsad_annotations_filters_by_nipsa():
    query = search.nipsad_annotations("test_userid")

    must_clauses = query["query"]["filtered"]["filter"]["bool"]["must"]
    assert {"term": {"nipsa": True}} in must_clauses
示例#5
0
def test_nipsad_annotations_filters_by_lowercased_userid():
    query = search.nipsad_annotations("SomethingWithUppercase")

    must_clauses = query["query"]["filtered"]["filter"]["bool"]["must"]
    assert {"term": {"user": "******"}} in must_clauses
示例#6
0
def test_nipsad_annotations_filters_by_nipsa():
    query = search.nipsad_annotations("test_userid")

    must_clauses = query["query"]["filtered"]["filter"]["bool"]["must"]
    assert {"term": {"nipsa": True}} in must_clauses
示例#7
0
def remove_nipsa(userid):
    log.info("clearing nipsa flag for user annotations: %s", userid)

    bulk_update_annotations(celery.request.es,
                            search.nipsad_annotations(userid),
                            remove_nipsa_action)
示例#8
0
文件: worker.py 项目: nlisgo/h
def remove_nipsa(userid):
    log.info("clearing nipsa flag for user annotations: %s", userid)

    bulk_update_annotations(celery.request.es,
                            search.nipsad_annotations(userid),
                            remove_nipsa_action)
示例#9
0
文件: search_test.py 项目: nlisgo/h
def test_nipsad_annotations_filters_by_lowercased_userid():
    query = search.nipsad_annotations("SomethingWithUppercase")

    must_clauses = query["query"]["filtered"]["filter"]["bool"]["must"]
    assert {"term": {"user": "******"}} in must_clauses