Skip to content

Commit

Permalink
fix: pendulum swings
Browse files Browse the repository at this point in the history
  • Loading branch information
aaxelb committed Jul 28, 2021
1 parent 16efdc9 commit 2d00b73
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion share/harvesters/gov_nsfawards.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def shift_range(self, start_date: pendulum.DateTime, end_date: pendulum.DateTime
# HACK: Records are made available one business day *after* their "date".
# Accounting for holidays, they might be delayed over a 4-day weekend.
# When harvesting yesterday's data, actually reach back farther...
if end_date.is_today():
if end_date.is_same_day(pendulum.now()):
start_date = start_date.subtract(days=5)
return start_date, end_date

Expand Down
4 changes: 2 additions & 2 deletions share/harvesters/oai.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ def _do_fetch(self, start_date, end_date, metadata_prefix, time_granularity=True
url.args['metadataPrefix'] = metadata_prefix

if time_granularity:
url.args['from'] = start_date.format('YYYY-MM-DDT00:00:00', formatter='alternative') + 'Z'
url.args['until'] = end_date.format('YYYY-MM-DDT00:00:00', formatter='alternative') + 'Z'
url.args['from'] = start_date.format('YYYY-MM-DD') + 'T00:00:00Z'
url.args['until'] = end_date.format('YYYY-MM-DD') + 'T00:00:00Z'
else:
url.args['from'] = start_date.date().isoformat()
url.args['until'] = end_date.date().isoformat()
Expand Down
4 changes: 2 additions & 2 deletions share/harvesters/org_dataone.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ class DataOneHarvester(BaseHarvester):
VERSION = 1

def do_harvest(self, start_date, end_date):
end_date = end_date.format('YYYY-MM-DDT00:00:00', formatter='alternative') + 'Z'
start_date = start_date.format('YYYY-MM-DDT00:00:00', formatter='alternative') + 'Z'
end_date = end_date.format('YYYY-MM-DD') + 'T00:00:00Z'
start_date = start_date.format('YYYY-MM-DD') + 'T00:00:00Z'

url = furl(self.config.base_url).set(query_params={
'q': 'dateModified:[{} TO {}]'.format(start_date, end_date),
Expand Down
4 changes: 2 additions & 2 deletions share/harvesters/org_ncar.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ def do_harvest(self, start_date, end_date):
url = furl(self.url).set(query_params={
'verb': 'ListRecords',
'metadataPrefix': 'dif',
'from': start_date.format('YYYY-MM-DDT00:00:00', formatter='alternative') + 'Z',
'until': end_date.format('YYYY-MM-DDT00:00:00', formatter='alternative') + 'Z'
'from': start_date.format('YYYY-MM-DD') + 'T00:00:00Z',
'until': end_date.format('YYYY-MM-DD') + 'T00:00:00Z',
})

return self.fetch_records(url)
Expand Down

0 comments on commit 2d00b73

Please sign in to comment.