Closed AntVil closed 8 months ago
when the timezone includes a plus sign no data is shown. (it only shows No data in selected time range which is incorrect)
No data in selected time range
the problem is that the request sents the plus-sign as is, which doesn't work.
As an example the url:
https://api.openaq.org/v3/locations/1815690/measurements?period_name=hour&limit=1000¶meters_id=2&date_from=2023-11-08T10:06:13+01:00&date_to=2023-11-09T10:02:55+01:00
fails with this message:
"[{'type': 'datetime_parsing', 'loc': ('query', 'date_to', 'datetime'), 'msg': 'Input should be a valid datetime, invalid timezone sign', 'input': '2023-11-09T10:02:55 03:00', 'ctx': {'error': 'invalid timezone sign'}, 'url': 'https://errors.pydantic.dev/2.1.2/v/datetime_parsing'}, {'type': 'date_from_datetime_parsing', 'loc': ('query', 'date_to', 'date'), 'msg': 'Input should be a valid date or datetime, invalid timezone sign', 'input': '2023-11-09T10:02:55 03:00', 'ctx': {'error': 'invalid timezone sign'}, 'url': 'https://errors.pydantic.dev/2.1.2/v/date_from_datetime_parsing'}]"
when the plus sign is percent-encoded as %2b it doesn't fail anymore. the url would be:
%2b
https://api.openaq.org/v3/locations/1815690/measurements?period_name=hour&limit=1000¶meters_id=2&date_from=2023-11-08T10:06:13%2b01:00&date_to=2023-11-09T10:02:55%2b01:00
looking into the code it seems each time toISOString is called there should also be an percent encoding using encodeURIComponent or even just a simple replace replace. All the related code seems to be in the file:
toISOString
encodeURIComponent
replace
openaq-explorer/src/components/DetailCharts/index.jsx
Thanks for flagging this. We have a new version of Explorer launching soon, this issue is resolved in the upcoming release.
when the timezone includes a plus sign no data is shown. (it only shows
No data in selected time range
which is incorrect)the problem is that the request sents the plus-sign as is, which doesn't work.
As an example the url:
https://api.openaq.org/v3/locations/1815690/measurements?period_name=hour&limit=1000¶meters_id=2&date_from=2023-11-08T10:06:13+01:00&date_to=2023-11-09T10:02:55+01:00
fails with this message:
when the plus sign is percent-encoded as
%2b
it doesn't fail anymore. the url would be:https://api.openaq.org/v3/locations/1815690/measurements?period_name=hour&limit=1000¶meters_id=2&date_from=2023-11-08T10:06:13%2b01:00&date_to=2023-11-09T10:02:55%2b01:00
looking into the code it seems each time
toISOString
is called there should also be an percent encoding usingencodeURIComponent
or even just a simple replacereplace
. All the related code seems to be in the file:openaq-explorer/src/components/DetailCharts/index.jsx