Skip to content

Commit

Permalink
Merge pull request #96 from spacemansteve/master
Browse files Browse the repository at this point in the history
more flags for resources
  • Loading branch information
spacemansteve committed Apr 30, 2019
2 parents 51186f0 + 5c9011a commit 253e48f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
9 changes: 8 additions & 1 deletion adsmp/solr_updater.py
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,14 @@ def transform_json_record(db_record):
if 'property' not in out:
out['property'] = []
if links_data.get('access', None) == 'open':
out['property'].append('ESOURCE')
out['property'].extend(['ESOURCE',
'ARTICLE',
'NOT REFEREED',
'EPRINT_OPENACCESS',
'OPENACCESS'])
if 'esources' not in out:
out['esources'] = []
out['esources'].extend(['EPRINT_HTML', 'EPRINT_PDF'])
except (KeyError, ValueError):
# here if record holds unexpected value
logger.error('invalid value in bib data, bibcode = {}, type = {}, value = {}'.format(db_record['bibcode'], type(links_data), links_data))
Expand Down
7 changes: 7 additions & 0 deletions adsmp/tests/test_solr_updater.py
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,13 @@ def test_links_data_merge(self):
'bib_data_updated': datetime.now()}
solr_record = solr_updater.transform_json_record(db_record)
self.assertTrue('ESOURCE' in solr_record['property'])
# verify all values are populated
self.assertTrue('ARTICLE' in solr_record['property'])
self.assertTrue('NOT REFEREED' in solr_record['property'])
self.assertTrue('EPRINT_OPENACCESS' in solr_record['property'])
self.assertTrue('OPENACCESS' in solr_record['property'])
self.assertTrue('EPRINT_HTML' in solr_record['esources'])
self.assertTrue('EPRINT_PDF' in solr_record['esources'])

db_record = {'bibcode': 'foo',
'bib_data': {'links_data': ['{"url": "http://foo", "access": "closed"}']},
Expand Down

0 comments on commit 253e48f

Please sign in to comment.