SciPost Code Repository

Skip to content
Snippets Groups Projects
Commit 2780dd82 authored by Jorran de Wit's avatar Jorran de Wit
Browse files

Fix ArXiv query

parent 612d4287
No related branches found
No related tags found
No related merge requests found
......@@ -1392,8 +1392,7 @@ def prepare_for_voting(request, rec_id):
fellows_with_expertise = recommendation.submission.fellows.filter(
contributor__expertises__contains=[recommendation.submission.subject_area])
coauthorships = {}
coauthorships = []
eligibility_form = VotingEligibilityForm(request.POST or None, instance=recommendation)
if eligibility_form.is_valid():
eligibility_form.save()
......@@ -1408,21 +1407,26 @@ def prepare_for_voting(request, rec_id):
else:
# Identify possible co-authorships in last 3 years, disqualifying Fellow from voting:
if recommendation.submission.metadata is not None:
author_last_names = []
for author in recommendation.submission.metadata['entries'][0]['authors']:
# Gather author data to do conflict-of-interest queries with
author_last_names.append(author['name'].split()[-1])
fellow_last_names = []
for fellow in fellows_with_expertise:
sub_auth_boolean_str = '((' + (recommendation.submission
.metadata['entries'][0]['authors'][0]['name']
.split()[-1])
for author in recommendation.submission.metadata['entries'][0]['authors'][1:]:
sub_auth_boolean_str += '+OR+' + author['name'].split()[-1]
sub_auth_boolean_str += ')+AND+'
search_str = sub_auth_boolean_str + fellow.contributor.user.last_name + ')'
queryurl = ('http://export.arxiv.org/api/query?search_query=au:%s'
% search_str + '&sortBy=submittedDate&sortOrder=descending'
'&max_results=5')
arxivquery = feedparser.parse(queryurl)
queryresults = arxivquery
if queryresults.entries:
coauthorships[fellow.contributor.user.last_name] = queryresults
# For each fellow found, so a query with the authors to check for conflicts
fellow_last_names.append(fellow.contributor.user.last_name)
search_query = 'au:(({fellows})+AND+({authors}))'.format(
fellows='+OR+'.join(fellow_last_names),
authors='+OR+'.join(author_last_names))
queryurl = 'https://export.arxiv.org/api/query?search_query={sq}'.format(
sq=search_query)
queryurl += '&sortBy=submittedDate&sortOrder=descending&max_results=5'
queryurl = queryurl.replace(' ', '+') # Fallback for some last names with spaces
queryresults = feedparser.parse(queryurl)
if queryresults.entries:
coauthorships = queryresults
context = {
'recommendation': recommendation,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment