Beispiel #1
0
def add_nipsa(userid):
    log.info("setting nipsa flag for user annotations: %s", userid)

    if celery.request.feature('postgres'):
        bulk_update_annotations(celery.request.es,
                                search.not_nipsad_annotations(userid),
                                add_nipsa_action)

    bulk_update_annotations(celery.request.legacy_es,
                            search.not_nipsad_annotations(userid),
                            add_nipsa_action)
Beispiel #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)
Beispiel #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)
Beispiel #4
0
def test_not_nipsad_annotations_filters_by_nipsa():
    query = search.not_nipsad_annotations("test_userid")

    must_clauses = query["query"]["filtered"]["filter"]["bool"]["must"]
    assert {"not": {"term": {"nipsa": True}}} in (must_clauses)
Beispiel #5
0
def test_not_nipsad_annotatopns_filters_by_userid():
    query = search.not_nipsad_annotations("test_userid")

    must_clauses = query["query"]["filtered"]["filter"]["bool"]["must"]
    assert {"term": {"user": "******"}} in must_clauses
Beispiel #6
0
def test_not_nipsad_annotations_filters_by_nipsa():
    query = search.not_nipsad_annotations("test_userid")

    must_clauses = query["query"]["filtered"]["filter"]["bool"]["must"]
    assert {"not": {"term": {"nipsa": True}}} in (
        must_clauses)
Beispiel #7
0
def test_not_nipsad_annotatopns_filters_by_userid():
    query = search.not_nipsad_annotations("test_userid")

    must_clauses = query["query"]["filtered"]["filter"]["bool"]["must"]
    assert {"term": {"user": "******"}} in must_clauses
Beispiel #8
0
def add_nipsa(userid):
    log.info("setting nipsa flag for user annotations: %s", userid)

    bulk_update_annotations(celery.request.es,
                            search.not_nipsad_annotations(userid),
                            add_nipsa_action)
Beispiel #9
0
def add_nipsa(userid):
    log.info("setting nipsa flag for user annotations: %s", userid)

    bulk_update_annotations(celery.request.es,
                            search.not_nipsad_annotations(userid),
                            add_nipsa_action)