From ad6e63b70d2ba32c98f4b17057c9778a9e7773c3 Mon Sep 17 00:00:00 2001 From: femalves Date: Mon, 15 Apr 2024 11:27:35 -0400 Subject: [PATCH] removing bibcode desc sorts --- vault_service/tests/test_user.py | 2 +- vault_service/tests/test_utils.py | 5 +++-- vault_service/views/user.py | 17 +++++++++-------- 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/vault_service/tests/test_user.py b/vault_service/tests/test_user.py index 3926999..a644149 100644 --- a/vault_service/tests/test_user.py +++ b/vault_service/tests/test_user.py @@ -770,7 +770,7 @@ def test_myads_execute_notification(self): self.assertStatus(r, 200) self.assertEqual(r.json, [{'q': 'author:"Kurtz, Michael" entdate:["{0}Z00:00" TO "{1}Z23:59"] ' 'pubdate:[{2}-00 TO *]'.format(start_date, now, beg_pubyear), - 'sort': 'score desc, bibcode desc'}]) + 'sort': 'score desc, date desc'}]) @httpretty.activate def test_myads_import(self): diff --git a/vault_service/tests/test_utils.py b/vault_service/tests/test_utils.py index b5cc6a5..04ed226 100644 --- a/vault_service/tests/test_utils.py +++ b/vault_service/tests/test_utils.py @@ -38,9 +38,10 @@ def test_exc(): self.assertTrue(r == {'query': 'fq=%7B%21bitset%7D&q=foo', 'bigquery': 'foo\nbar'}) # Typical general myADS notification - r = utils.cleanup_payload({'query': {'fq': ['{!type=aqp v=$fq_database}'], 'fq_database': ['(database:astronomy)'], 'q': ['star'], 'sort': ['citation_count desc, bibcode desc']}, + r = utils.cleanup_payload({'query': {'fq': ['{!type=aqp v=$fq_database}'], 'fq_database': ['(database:astronomy)'], 'q': ['star'], 'sort': ['citation_count desc, date desc']}, }) - self.assertTrue(r == {'bigquery': '', 'query': 'fq=%7B%21type%3Daqp+v%3D%24fq_database%7D&fq_database=%28database%3Aastronomy%29&q=star&sort=citation_count+desc%2C+bibcode+desc'}) + + self.assertTrue(r == {'bigquery': '', 'query': 'fq=%7B%21type%3Daqp+v%3D%24fq_database%7D&fq_database=%28database%3Aastronomy%29&q=star&sort=citation_count+desc%2C+date+desc'}) @httpretty.activate def test_upsert_myads(self): diff --git a/vault_service/views/user.py b/vault_service/views/user.py index 6cc04f8..6892c77 100644 --- a/vault_service/views/user.py +++ b/vault_service/views/user.py @@ -655,25 +655,26 @@ def _create_myads_query(template_type, frequency, data, classes=None, start_isod if frequency == 'daily': connector = [' ', ' NOT '] # keyword search should be sorted by score, "other recent" should be sorted by bibcode - sort_w_keywords = ['score desc, bibcode desc', 'bibcode desc'] + sort_w_keywords = ['score desc, date desc', 'date desc'] elif frequency == 'weekly': connector = [' '] - sort_w_keywords = ['score desc, bibcode desc'] + sort_w_keywords = ['score desc, date desc'] if not keywords: q = 'bibstem:arxiv {0} entdate:["{1}Z00:00" TO "{2}Z23:59"] pubdate:[{3}-00 TO *]'.\ format(classes, start_date, end_date, beg_pubyear) - sort = 'bibcode desc' + sort = 'date desc' out.append({'q': q, 'sort': sort}) else: for c, s in zip(connector, sort_w_keywords): q = 'bibstem:arxiv ({0}{1}({2})) entdate:["{3}Z00:00" TO "{4}Z23:59"] pubdate:[{5}-00 TO *]'.\ format(classes, c, keywords, start_date, end_date, beg_pubyear) sort = s + out.append({'q': q, 'sort': sort}) elif template_type == 'citations': keywords = data q = 'citations({0})'.format(keywords) - sort = 'entry_date desc, bibcode desc' + sort = 'entry_date desc, date desc' out.append({'q': q, 'sort': sort}) elif template_type == 'authors': keywords = data @@ -682,7 +683,7 @@ def _create_myads_query(template_type, frequency, data, classes=None, start_isod start_date = start_isodate q = '{0} entdate:["{1}Z00:00" TO "{2}Z23:59"] pubdate:[{3}-00 TO *]'.\ format(keywords, start_date, end_date, beg_pubyear) - sort = 'score desc, bibcode desc' + sort = 'score desc, date desc' out.append({'q': q, 'sort': sort}) elif template_type == 'keyword': keywords = data @@ -692,15 +693,15 @@ def _create_myads_query(template_type, frequency, data, classes=None, start_isod # most recent q = '{0} entdate:["{1}Z00:00" TO "{2}Z23:59"] pubdate:[{3}-00 TO *]'.\ format(keywords, start_date, end_date, beg_pubyear) - sort = 'entry_date desc, bibcode desc' + sort = 'entry_date desc, date desc' out.append({'q': q, 'sort': sort}) # most popular q = 'trending({0})'.format(keywords) - sort = 'score desc, bibcode desc' + sort = 'score desc, date desc' out.append({'q': q, 'sort': sort}) # most cited q = 'useful({0})'.format(keywords) - sort = 'score desc, bibcode desc' + sort = 'score desc, date desc' out.append({'q': q, 'sort': sort}) elif template_type is None and data: # General query - for consistency with the rest of templates,