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)
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)
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
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
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)