Closed ghukill closed 5 years ago
Is more detail available/is the issue easily replicable?
It should be readily reproducible. In a table that has numerous Jobs -- in a Record Group view, or All Jobs, etc. -- the timestamp column does not sort as expected.
Because there are likely a manageable number of Jobs at any one load, not thousands plus, the datatables instance receives a queryset directly from Django, I think. The sorting is done on the timestamp column, but believe it's sorting the string representation of a datetime field.
Ok, I was able to reproduce by ensuring that two Jobs had timestamps set to different days in June and another Job had a timestamp set to sometime in August.
I implemented the fix for the jobs datatable. Fixing it requires modifying the column in question and also ensuring that momentjs and a datatables plugin are loaded for the parent page. Should I just look for timestamp columns and fix them all?
Nice!
Modifying the column in the database? does it need to be something different than a Datetime type? or modifying how it comes out through the datatables endpoint views?
Oh, no, sorry, just requires modifying how the column is displayed in the template:
{{ job.timestamp|date:"M d, Y, h:i A" }}
Ah, phew! I reckon there could be a few errant ones to update, but hopefully not too many. And at least they are likely in tables which make for easy searching out! Thanks for fixing!
Tables with timestamps aren't sorting consistently...