MI-DPLA / combine

Combine /kämˌbīn/ - Metadata Aggregator Platform
MIT License
26 stars 11 forks source link

Timestamp sorts don't work #199

Closed ghukill closed 5 years ago

ghukill commented 6 years ago

Tables with timestamps aren't sorting consistently...

antmoth commented 5 years ago

Is more detail available/is the issue easily replicable?

ghukill commented 5 years ago

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.

antmoth commented 5 years ago

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.

antmoth commented 5 years ago

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?

ghukill commented 5 years ago

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?

antmoth commented 5 years ago

Oh, no, sorry, just requires modifying how the column is displayed in the template: {{ job.timestamp|date:"M d, Y, h:i A" }}

ghukill commented 5 years ago

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!