Пример #1
0
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
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