Skip to content

Commit

Permalink
removing bibcode desc sorts
Browse files Browse the repository at this point in the history
  • Loading branch information
femalves committed Apr 15, 2024
1 parent 2f49386 commit ad6e63b
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 11 deletions.
2 changes: 1 addition & 1 deletion vault_service/tests/test_user.py
Expand Up @@ -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):
Expand Down
5 changes: 3 additions & 2 deletions vault_service/tests/test_utils.py
Expand Up @@ -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):
Expand Down
17 changes: 9 additions & 8 deletions vault_service/views/user.py
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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,
Expand Down

0 comments on commit ad6e63b

Please sign in to comment.