def test_hep_collection_aggregation(inspire_app, override_config): config = { "RECORDS_REST_FACETS": { "filters": hep_filters(), "records-hep": {"aggs": {**hep_collection_aggregation(1)}}, } } with override_config(**config): data = {"_collections": ["Literature", "Fermilab"]} expected_record = create_record("lit", data) data = {"_collections": ["Fermilab"]} create_record("lit", data) with inspire_app.test_client() as client: response = client.get("/literature/facets").json expected_aggregation = { "meta": {"title": "Collection", "type": "checkbox", "order": 1}, "doc_count_error_upper_bound": 0, "sum_other_doc_count": 0, "buckets": [ {"key": "fermilab", "doc_count": 1}, {"key": "literature", "doc_count": 1}, ], } assert response["aggregations"]["collection"] == expected_aggregation with inspire_app.test_client() as client: response = client.get("/literature?collection=Literature").json assert len(response["hits"]["hits"]) == 1 assert ( response["hits"]["hits"][0]["metadata"]["control_number"] == expected_record["control_number"] )
def test_hep_experiment_papers_cataloger_facets(inspire_app): with current_app.test_request_context(): expected_filters = { "author", "author_count", "doc_type", "earliest_date", "citation_count", "citation_count_without_self_citations", "collaboration", "refereed", "citeable", "collection", "subject", "arxiv_categories", "self_affiliations", "self_author_names", "rpp", "affiliations", "self_curated_relation", } expected_aggregations = { **hep_earliest_date_aggregation(order=1), **hep_author_count_aggregation(order=2), **hep_doc_type_aggregation(order=3), **hep_subject_aggregation(order=4), **hep_collection_aggregation(order=5), } filters = current_app.config["CATALOGER_RECORDS_REST_FACETS"][ "hep-experiment-papers"]()["filters"].keys() aggregations = current_app.config["CATALOGER_RECORDS_REST_FACETS"][ "hep-experiment-papers"]()["aggs"] assert filters == expected_filters assert aggregations == expected_aggregations
def records_hep_cataloger(order=None): if order is None: order = count(start=1) records = records_hep(order=order) records["aggs"].update({ **hep_collection_aggregation(order=next(order)), **hep_curation_collection_aggregation(order=next(order)), }) return records
def hep_author_citations_cataloger(order=None): if order is None: order = count(start=1) records = hep_author_citations(order=order) records["aggs"].update({ **hep_subject_aggregation(order=next(order)), **hep_arxiv_categories_aggregation(order=next(order)), **hep_collection_aggregation(order=next(order)), }) return records
def test_hep_author_publications_cataloger_facets(inspire_app): author = "1111_Jones" author_recid = "1111" with current_app.test_request_context(f"?author={author}"): expected_filters = { "author", "author_count", "doc_type", "earliest_date", "citation_count", "citation_count_without_self_citations", "collaboration", "refereed", "citeable", "collection", "curation_collection", "subject", "arxiv_categories", "self_affiliations", "affiliations", "self_author_names", "self_curated_relation", "rpp", "experiments", } expected_aggregations = { **hep_earliest_date_aggregation(order=1, title="Date of paper"), **hep_author_count_aggregation(order=2), **hep_rpp(order=3), **hep_doc_type_aggregation(order=4), **hep_author_aggregation(order=5, author=author, title="Collaborators"), **hep_collaboration_aggregation(order=6), **hep_self_author_affiliations_aggregation(order=7, author_recid=author_recid), **hep_subject_aggregation(order=8), **hep_arxiv_categories_aggregation(order=9), **hep_self_author_names_aggregation(order=10, author_recid=author_recid), **hep_collection_aggregation(order=11), **hep_self_author_claimed_papers_aggregation(order=12, author_recid=author_recid), **hep_experiments_aggregation(order=13), } filters = set(current_app.config["CATALOGER_RECORDS_REST_FACETS"] ["hep-author-publication"]()["filters"].keys()) aggregations = current_app.config["CATALOGER_RECORDS_REST_FACETS"][ "hep-author-publication"]()["aggs"] assert filters == expected_filters assert aggregations == expected_aggregations
def hep_author_publications_cataloger(order=None): if order is None: order = count(start=1) author_recid = request.values.get("author", "", type=str).split("_")[0] records = hep_author_publications(order=order) records["aggs"].update({ **hep_subject_aggregation(order=next(order)), **hep_arxiv_categories_aggregation(order=next(order)), **hep_self_author_names_aggregation(order=next(order), author_recid=author_recid), **hep_collection_aggregation(order=next(order)), }) return records
def hep_experiment_papers_cataloger(order=None): if order is None: order = count(start=1) records = hep_experiment_papers(order=order) records["aggs"].update({**hep_collection_aggregation(order=next(order))}) return records