Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

removing bibcode desc sorts #75

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
28 changes: 28 additions & 0 deletions alembic/versions/15025c9be4f6_changed_sort.py
@@ -0,0 +1,28 @@
"""changed sort

Revision ID: 15025c9be4f6
Revises: ffdbd392dc89
Create Date: 2024-04-22 14:27:13.360604

"""

# revision identifiers, used by Alembic.
revision = '15025c9be4f6'
down_revision = 'ffdbd392dc89'

from alembic import op
import sqlalchemy as sa




def upgrade():
#with app.app_context() as c:
# db.session.add(Model())
# db.session.commit()

pass


def downgrade():
pass
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