Skip to content

Commit cf2778b

Browse files
committed
ensure properties and ids contain ISO8601-compliant datetime
1 parent 9216827 commit cf2778b

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

msc_pygeoapi/loader/hydrometric_realtime.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
from msc_pygeoapi.util import (
4242
check_es_indexes_to_delete,
4343
configure_es_connection,
44+
DATETIME_RFC3339_FMT
4445
)
4546

4647

@@ -60,7 +61,7 @@
6061
SETTINGS = {
6162
'order': 0,
6263
'version': 1,
63-
'index_patterns': [INDEX_BASENAME],
64+
'index_patterns': [f'{INDEX_BASENAME}*'],
6465
'settings': {
6566
'number_of_shards': 1,
6667
'number_of_replicas': 0
@@ -98,7 +99,7 @@
9899
},
99100
'DATETIME': {
100101
'type': 'date',
101-
'format': 'strict_date_hour_minute_second||strict_date_optional_time' # noqa
102+
'format': 'date_time_no_millis||strict_date_optional_time' # noqa
102103
},
103104
'DATETIME_LST': {
104105
'type': 'date',
@@ -284,11 +285,10 @@ def generate_observations(self, filepath):
284285
try:
285286
# Convert timestamp to UTC time.
286287
utc_datetime = delocalize_date(date_)
287-
utc_datestamp = utc_datetime.strftime('%Y-%m-%d.%H:%M:%S')
288+
utc_datestamp = utc_datetime.strftime(DATETIME_RFC3339_FMT)
288289
# Generate an ID now that all fields are known.
289290
observation_id = f'{station}.{utc_datestamp}'
290291

291-
utc_datestamp = utc_datestamp.replace('.', 'T')
292292
except Exception as err:
293293
LOGGER.error(f'Cannot interpret datetime value {date_} in {filepath}' # noqa
294294
f' due to: {err} (skipping)')

0 commit comments

Comments
 (0)