Skip to content

Commit

Permalink
Merge pull request #240 from kelockhart/classic-entrydate
Browse files Browse the repository at this point in the history
Adjust Classic ingest entry_date for local vs UTC time
  • Loading branch information
seasidesparrow authored Feb 5, 2020
2 parents 1f52da9 + d543cf3 commit 3dd7660
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 10 deletions.
6 changes: 4 additions & 2 deletions aip/classic/solr_adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import sys
import re
import traceback
import datetime


from adsputils import setup_logging, get_date, date2solrstamp
Expand Down Expand Up @@ -276,8 +277,9 @@ def _database(ADS_record):

@staticmethod
def _entry_date(ADS_record):
d = ADS_record.get('entry_date', None)
return {'entry_date': date2solrstamp(d and get_date(d) or get_date())}
d = ADS_record.get('entry_date', None)
# Add one day to entry date to account for local (Classic) vs. UTC (direct ingest) time
return {'entry_date': date2solrstamp(d and get_date(d)+datetime.timedelta(days=1) or get_date())}

@staticmethod
def _year(ADS_record):
Expand Down
16 changes: 8 additions & 8 deletions tests/classic/test_solr_adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def test_SolrAdapter(self):
'doctype_facet_hier': [u'0/Non-Article', u'1/Non-Article/Catalog'],
'doi': [u'doi:\xc5\xbd\xc5\xa0\xc4\x8c\xc5\x98\xc4\x8e\xc5\xa4\xc5\x87:123456789'],
'email': [u'-', u'[email protected]', u'-'],
'entry_date': '2003-03-21T00:00:00.000000Z',
'entry_date': '2003-03-22T00:00:00.000000Z',
'first_author': u"t'Hooft, van X",
'first_author_facet_hier': [u'0/T Hooft, V', u"1/T Hooft, V/t'Hooft, van X"],
'first_author_norm': u'T Hooft, V',
Expand Down Expand Up @@ -68,7 +68,7 @@ def test_SolrAdapter(self):
self.assertEquals(r, {
"first_author": u"Kurtz, Michael J.",
# "links_data": [u"{\"title\":\"\",\"type\":\"spires\",\"instances\":\"\"}", "{\"title\":\"\",\"type\":\"electr\",\"instances\":\"\"}", "{\"title\":\"\",\"type\":\"spires\",\"instances\":\"\"}"],
"entry_date": '2003-03-21T00:00:00.000000Z',
"entry_date": '2003-03-22T00:00:00.000000Z',
"first_author_norm": u"Kurtz, M",
"year": u"2000",
"bibcode": u"2000A&AS..143...41K_test",
Expand Down Expand Up @@ -179,7 +179,7 @@ def test_SolrAdapter(self):
'date': u'2014-06-01T00:00:00.000000Z',
'bibstem': [u'arXiv', u'arXiv1406'],
'bibstem_facet': u'arXiv',
'entry_date': '2003-02-21T00:00:00.000000Z',
'entry_date': '2003-02-22T00:00:00.000000Z',
'pubdate' : u'2014-06-00',
'doctype': u'article',

Expand Down Expand Up @@ -249,7 +249,7 @@ def test_SolrAdapter(self):
'date': u'2014-06-01T00:00:00.000000Z',
'bibstem': [u'arXiv', u'arXiv1406'],
'bibstem_facet': u'arXiv',
'entry_date': '2003-02-21T00:00:00.000000Z',
'entry_date': '2003-02-22T00:00:00.000000Z',
'pubdate': u'2014-06-00',
'doctype': u'article',

Expand Down Expand Up @@ -319,7 +319,7 @@ def test_SolrAdapter(self):
'date': u'2018-07-30T00:30:00.000000Z',
'bibstem': [u'arXiv', u'arXiv1807'],
'bibstem_facet': u'arXiv',
'entry_date': '2018-07-30T00:00:00.000000Z',
'entry_date': '2018-07-31T00:00:00.000000Z',
'pubdate': u'2018-07-30',
'doctype': u'article',

Expand Down Expand Up @@ -402,7 +402,7 @@ def test_SolrAdapter(self):
'date': u'1968-09-01T00:00:00.000000Z',
'bibstem': [u'NuPhB', u'NuPhB...7'],
'bibstem_facet': u'NuPhB',
'entry_date': '2004-06-09T00:00:00.000000Z',
'entry_date': '2004-06-10T00:00:00.000000Z',
'pubdate': u'1968-09-00',
'doctype': u'article',

Expand Down Expand Up @@ -474,7 +474,7 @@ def test_SolrAdapter(self):
'date': u'2018-02-01T00:00:00.000000Z',
'bibstem': [u'ascl', u'ascl.soft'],
'bibstem_facet': u'ascl.soft',
'entry_date': '2004-06-09T00:00:00.000000Z',
'entry_date': '2004-06-10T00:00:00.000000Z',
'pubdate': u'2018-02-00',
'doctype': u'software',

Expand Down Expand Up @@ -539,7 +539,7 @@ def test_SolrAdapter(self):
'date': u'1988-04-01T00:00:00Z',
'bibstem': [u'Sci', u'Sci...240'],
'bibstem_facet': u'Sci',
'entry_date': '2002-06-26T00:00:00.000000Z',
'entry_date': '2002-06-27T00:00:00.000000Z',
'pubdate': u'1988-04-00',
'date': u'1988-04-01T00:00:00.000000Z',
'doctype': u'article',
Expand Down
1 change: 1 addition & 0 deletions tests/classic/test_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ def test_task_merge_metadata(self):

out = copy.deepcopy(mergerdata.MERGEDRECS['2015ApJ...815..133S'])
out['id'] = 1
out['entry_date'] = '2003-01-02T00:00:00.000000Z'

tasks.task_merge_metadata(ADSRECORDS['2015ApJ...815..133S'])
self.assertTrue(next_task.called)
Expand Down

0 comments on commit 3dd7660

Please sign in to comment.