From 36d59561ee290a4b7d503c0a49522db9608ec3ed Mon Sep 17 00:00:00 2001 From: Thomas Eidens Date: Fri, 15 Dec 2023 12:27:30 +0100 Subject: [PATCH] Fixed publishedIn filter in /v2/papers API endpoint --- neoflask/queries.py | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/neoflask/queries.py b/neoflask/queries.py index e1f3a7af..5b7d66ec 100644 --- a/neoflask/queries.py +++ b/neoflask/queries.py @@ -220,23 +220,35 @@ class REFEREED_PREPRINTS_V2(Query): OR $reviewed_by = [] OR review_service.name IN $reviewed_by ) +WITH doisFulltextSearch, review_service // filter by query if requested -MATCH (review_service)-[:HasPaper]->(paper:VizPaper) +MATCH (review_service)-[:HasPaper]->(vzp:VizPaper) WHERE - ($lucene_query IS NULL OR paper.doi in doisFulltextSearch) - AND ( - $published_in IS NULL - OR $published_in = [] - OR toLower(paper.published_journal_title) IN $published_in + ( + $lucene_query IS NULL + OR vzp.doi in doisFulltextSearch ) +WITH vzp + +// filter by publisher +MATCH (a:Article {doi: vzp.doi}) +WHERE ( + $published_in IS NULL + OR $published_in = [] + OR ( + NOT isEmpty(a.published_journal_title) + AND a.published_journal_title IN $published_in + ) +) +WITH vzp // figure out how to sort based on the provided parameters -MATCH (paper)-[:HasReviewDate]->(revdate:VizReviewDate) +MATCH (vzp)-[:HasReviewDate]->(revdate:VizReviewDate) WITH - paper.doi AS doi, + vzp.doi AS doi, { - preprint_date: paper.pub_date, + preprint_date: vzp.pub_date, review_date: revdate.date } AS sort_fields // for the parameterized sort, see below WITH