Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Date sorting on the Notifications page is not date sorting #1653

Closed
vantuyls opened this issue Sep 11, 2017 · 6 comments
Closed

Date sorting on the Notifications page is not date sorting #1653

vantuyls opened this issue Sep 11, 2017 · 6 comments
Assignees
Labels
Milestone

Comments

@vantuyls
Copy link

Descriptive summary

The notifications page allows the notification table to be sortable by date (among other things) but the sorting on this field isn't actually sorting on date, it is sorting alphanumerically on the text in the date field.

Expected behavior

Sorting the Date field in this (or any) table should sort on date/time

Actual behavior

Sorting the Date field in this table sorts alphanumerically

Steps to reproduce the behavior

  1. look at notifications tab
  2. sort by date
  3. alphanumeric!
@jcoyne
Copy link
Member

jcoyne commented Sep 12, 2017

@vantuyls what version? I thought this was fixed by #1416

@jcoyne
Copy link
Member

jcoyne commented Sep 12, 2017

Ah, maybe :long_ordinal was a poor choice if the notifications span a month boundary. Maybe :db would have been better.

@vantuyls
Copy link
Author

vantuyls commented Sep 12, 2017

this was observed on 2alpha.

@mjgiarlo
Copy link
Member

@vantuyls I'd like to tag this with the 2.0.0 milestone, but that milestone is currently polluted with many many issues. Might you have time to work w/ me on clearing out that milestone so we can make it useful for us?

@vantuyls
Copy link
Author

Can do.

@blackrat
Copy link

blackrat commented Feb 6, 2018

This seems to be a basic misunderstanding of how dataTables sorting works.
If you set a 'data-sort' option on the <td>, dataTables will use that for sorting rather than the generated content.

i.e. in _notifications.html.erb
<td data-sort="<%= msg.last_message.created_at.getutc.iso8601 %>">

will be sort by the iso8601 representation of the date as opposed to the underlying relative-time string. The (:long_ordinal) content will just be a default form displayed if the relative-time fails to correctly parse the relative-time datetime element.

@no-reply no-reply self-assigned this Mar 1, 2018
no-reply pushed a commit that referenced this issue Mar 1, 2018
Adding a `data-sort` with ISO 8601 datetimes allows dataTables to sort
independent of the visible row values. We continue to use javascript to generate
the human-readable time for the reasons given in  #1416 (support for page
caching).

Fixes #1653.
no-reply pushed a commit that referenced this issue Mar 1, 2018
Adding a `data-sort` with ISO 8601 datetimes allows dataTables to sort
independent of the visible row values. We continue to use javascript to generate
the human-readable time for the reasons given in  #1416 (support for page
caching).

Fixes #1653.
no-reply pushed a commit that referenced this issue Mar 1, 2018
Adding a `data-sort` with ISO 8601 datetimes allows dataTables to sort
independent of the visible row values. We continue to use javascript to generate
the human-readable time for the reasons given in  #1416 (support for page
caching).

We sort to `#iso8601(5)` (i.e. to 5 decimal places). This still allows a
mismatch between displayed times and correctly sorted times (off by one second),
apparently due to rounding behavior in the javascript sort dates. The actual
dates sort correctly, so display dates sort themselves out (ha!) as a
notification ages past one minute.

Fixes #1653.
no-reply pushed a commit that referenced this issue Mar 2, 2018
Adding a `data-sort` with ISO 8601 datetimes allows dataTables to sort
independent of the visible row values. We continue to use javascript to generate
the human-readable time for the reasons given in  #1416 (support for page
caching).

We sort to `#iso8601(5)` (i.e. to 5 decimal places). This still allows a
mismatch between displayed times and correctly sorted times (off by one second),
apparently due to rounding behavior in the javascript sort dates. The actual
dates sort correctly, so display dates sort themselves out (ha!) as a
notification ages past one minute.

Fixes #1653.
no-reply pushed a commit that referenced this issue Mar 2, 2018
Adding a `data-sort` with ISO 8601 datetimes allows dataTables to sort
independent of the visible row values. We continue to use javascript to generate
the human-readable time for the reasons given in  #1416 (support for page
caching).

We sort to `#iso8601(5)` (i.e. to 5 decimal places). This still allows a
mismatch between displayed times and correctly sorted times (off by one second),
apparently due to rounding behavior in the javascript sort dates. The actual
dates sort correctly, so display dates sort themselves out (ha!) as a
notification ages past one minute.

Fixes #1653.
no-reply pushed a commit that referenced this issue Mar 7, 2018
Adding a `data-sort` with ISO 8601 datetimes allows dataTables to sort
independent of the visible row values. We continue to use javascript to generate
the human-readable time for the reasons given in  #1416 (support for page
caching).

We sort to `#iso8601(5)` (i.e. to 5 decimal places). This still allows a
mismatch between displayed times and correctly sorted times (off by one second),
apparently due to rounding behavior in the javascript sort dates. The actual
dates sort correctly, so display dates sort themselves out (ha!) as a
notification ages past one minute.

Fixes #1653.
no-reply pushed a commit that referenced this issue Mar 7, 2018
Fixes date sorting on notifications and other DataTables; #1653, #2754.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants