Skip to content

Commit

Permalink
Add 59 minute grace period (#20)
Browse files Browse the repository at this point in the history
* Add 59 minute grace period

Set a 'day' period to be 24 hours 59 minutes 59 seconds

* Remove trailing commas

Co-Authored-By: Tom Kralidis <tomkralidis@gmail.com>

Co-authored-by: Tom Kralidis <tomkralidis@gmail.com>
  • Loading branch information
webb-ben and tomkralidis committed Oct 24, 2022
1 parent 6935f5c commit d3429cf
Showing 1 changed file with 13 additions and 15 deletions.
28 changes: 13 additions & 15 deletions wis2box_api/plugins/process/station_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,34 +50,34 @@
'keywords': {'en': ['collection', 'topic', 'dataset']},
'schema': {
'type': 'string',
'default': None,
'default': None
},
'minOccurs': 1,
'maxOccurs': 1,
'metadata': None, # TODO how to use?
'metadata': None # TODO how to use?
},
'wigos_station_identifier': {
'title': {'en': 'WIGOS Station Identifier'},
'schema': {
'type': 'array',
'minItems': 1,
'items': {'type': 'string'},
'items': {'type': 'string'}
},
'minOccurs': 0,
'maxOccurs': 1,
'metadata': None, # TODO how to use?
'metadata': None # TODO how to use?
},
'days': {
'title': {'en': 'Days'},
'schema': {'type': 'number', 'default': 1},
'minOccurs': 0,
'maxOccurs': 1,
'maxOccurs': 1
},
'years': {
'title': {'en': 'Years'},
'schema': {'type': 'number', 'default': 0},
'minOccurs': 0,
'maxOccurs': 1,
'maxOccurs': 1
},
},
'outputs': {
Expand All @@ -89,15 +89,15 @@
},
'schema': {
'type': 'object',
'contentMediaType': 'application/json',
},
'contentMediaType': 'application/json'
}
}
},
'example': {
'inputs': {
'collection': 'mwi.mwi_met_centre.data.core.weather.surface-based-observations.SYNOP', # noqa
'collection': 'mwi.mwi_met_centre.data.core.weather.surface-based-observations.SYNOP' # noqa
}
},
}
}


Expand Down Expand Up @@ -148,7 +148,8 @@ def execute(self, data):
raise ProcessorExecuteError(msg)

days = data.get('days', 1) + (data.get('years', 0) * 365)
date_offset = (datetime.utcnow() - timedelta(days=days)).isoformat()
_time_delta = timedelta(days=days, minutes=59, seconds=59)
date_offset = (datetime.utcnow() - _time_delta).isoformat()

if CONFIG['resources'].get('stations') is None:
msg = 'stations collection does not exist'
Expand Down Expand Up @@ -182,10 +183,7 @@ def execute(self, data):
},
'aggs': {
'count': {
'terms': {
'field': 'reportId.raw',
'size': 64000
}
'terms': {'field': 'reportId.raw', 'size': 64000}
}
}
}
Expand Down

0 comments on commit d3429cf

Please sign in to comment.