stanfordnmbl / opencap-api

Apache License 2.0
5 stars 7 forks source link

dev: reduce processed fields clutter in list view #223

Closed carmichaelong closed 2 weeks ago

carmichaelong commented 2 weeks ago

shorten some column names and clean up duration formatting

carmichaelong commented 2 weeks ago

@AlbertoCasasOrtiz thanks for the catch (i should set up a local build at some point). pushed a commit that should fix the issue

AlbertoCasasOrtiz commented 2 weeks ago

It fixed it! I got then the same problem with processed_count and added a function too so it recognizes it.

Now, when I go to admin console, I got this:

   File "C:\Workspaces\opencap\opencap-api\mcserver\admin.py", line 117, in formatted_duration
     hours, remainder = divmod(int(obj.duration.total_seconds()), 3600)
 AttributeError: 'Trial' object has no attribute 'duration'
 [02/Oct/2024 11:13:48] "GET /admin/mcserver/trial/ HTTP/1.1" 500 452129

Looks like the obj.duration inside of the formatted_duration function is not being recognized.

carmichaelong commented 2 weeks ago

Thanks for checking that. Makes sense that it didn't work. I pushed a change because the field name is processed_duration (rather than just duration).

AlbertoCasasOrtiz commented 2 weeks ago

That solved the problem, but It was failing now complaining about total_seconds.

Since processed duration can be null or blank, it could not access to the total_seconds() for a non-defined object. I added an if-else (I returned the object as is without formatting in the case it is undefined, so check if that is what we want).

I just tested and it is showing the duration as expected for at least two trials:

carmichaelong commented 2 weeks ago

Awesome, yes, that's the formatting that I was going for! LGTM.