speedruncomorg / api

REST API Documentation for speedrun.com
346 stars 36 forks source link

Can't distinguish whether time that has decimal seconds or not when decimal seconds is .000 #168

Open Nanahuse opened 1 year ago

Nanahuse commented 1 year ago

When I retrieve a time value from the API that includes decimal seconds but the value is ".000," the decimal portion gets omitted. As a result, it becomes unclear whether it includes the decimal seconds. "Time that has decimal places" is not equivalent to "Time that DONT has decimal places". However, they look same value.

Example: Time is 40.000:

Currently API output:

"times":{
"primary":"40S"
......

Expected output:

"times":{
"primary":"40.000S"
......
exodustx0 commented 1 year ago

A workaround could be adding the query parameter embed=game and checking game.data.ruleset["show-milliseconds"], though it's obviously not ideal due to the extra load. Could get that value through a separate GET request for the game and cache it, but the effectiveness depends on your use-case.

Nanahuse commented 1 year ago

Thanks for the advice. In games with a large number of runs, only fast times have a decimal seconds. it depend on time. In my case, it is not solved.