Date/time issues after posting example code to "playlog" and "clock" endpoints
I've feed some modified example POST
requests to the "playlog" and "clock" endpoints. Compare the example as part of Swagger UI at http://localhost:8008/api/v1/ui and https://api.aura.radio/engine/.
Click to expand POST playlog
Payload:{
"customJson": "{ \"custom\": \"Stringified JSON Object\" }",
"isSynced": true,
"logSource": 1,
"playlistId": 38,
"showId": 42,
"showName": "Electronic Music from Brazil",
"timeslotId": 23,
"trackAlbum": "Bricolage",
"trackArtist": "Amon Tobin",
"trackDuration": 8808.8,
"trackNum": 11,
"trackStart": "2024-02-06T14:15:33.001Z",
"trackTitle": "Chomp Samba",
"trackType": 2
}
Click to expand: POST clock
Payload:{
"currentTimeslot": {
"playlistId": 38,
"playlistType": 0,
"showId": 42,
"showName": "Electronic Music from Brazil",
"timeslotEnd": "2024-02-28T09:12:33.001000+00:00",
"timeslotId": 23,
"timeslotStart": "2024-02-06T09:12:33.001000+00:00"
},
"currentTrack": {
"customJson": "{ \"custom\": \"Stringified JSON Object\" }",
"isSynced": true,
"logSource": 1,
"playlistId": 38,
"showId": 42,
"showName": "Electronic Music from Brazil",
"timeslotId": 23,
"trackAlbum": "Bricolage",
"trackArtist": "Amon Tobin",
"trackDuration": 72000,
"trackNum": 11,
"trackStart": "2024-02-06T09:12:33.001000+00:00",
"trackTitle": "Chomp Samba",
"trackType": 2
},
"engineSource": 1,
"plannedPlaylist": {
"entries": [
{
"trackAlbum": "Bricolage",
"trackArtist": "Amon Tobin",
"trackDuration": 72000,
"trackNum": 7,
"trackStart": "2024-02-06T09:12:33.001000+00:00",
"trackTitle": "Chomp Samba",
"trackType": 2
},
{
"trackAlbum": "Bricolage",
"trackArtist": "Amon Tobin",
"trackDuration": 808.8,
"trackNum": 7,
"trackStart": "2024-02-07T05:12:33.001000+00:00",
"trackTitle": "Chomp Samba",
"trackType": 2
}
],
"playlistId": 38
}
}
When calling the GET clock
endpoint, this results in an internal server error:
File "/home/david/code/aura/engine-api/src/aura_engine_api/rest/controllers/internal_controller.py", line 35, in clock_info
return service.get_clock_info()
^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/david/code/aura/engine-api/src/aura_engine_api/service.py", line 221, in get_clock_info
if timeslot_end < now:
^^^^^^^^^^^^^^^^^^
TypeError: can't compare offset-naive and offset-aware datetimes
127.0.0.1 - - [06/Feb/2024 14:47:30] "GET /api/v1/clock HTTP/1.1" 500 -
Suggested solution
- Implement test cases to cover these date/time/TZ scenarios
- Fix API docs inconsistencies or potential bugs in API implementation
- Think about generally converting dates, before comparing them, to a UNIX epoch timestamp. See how
engine
is dealing with that.
Edited by David Trattnig