Skip to content

Fix execution window sorting for non-English locales and use user's date format preference#758

Merged
chrismaddalena merged 4 commits intomasterfrom
copilot/fix-projects-sorting-issue
Nov 7, 2025
Merged

Fix execution window sorting for non-English locales and use user's date format preference#758
chrismaddalena merged 4 commits intomasterfrom
copilot/fix-projects-sorting-issue

Conversation

Copy link
Contributor

Copilot AI commented Nov 7, 2025

Identify the Bug

Fixes #194, #193, #282

Description of the Change

TableSorter's sorter-date-range-dMMMyyyy parser only recognizes English month abbreviations. When dates render in German ("Mai") or French ("Déc"), parsing fails and sorting degrades to alphabetic ordering, breaking chronological sort.

Added data-text attributes with ISO 8601 dates to execution window cells. TableSorter reads data-text first (via its textAttribute config), enabling locale-independent sorting. Additionally, changed date display format from hardcoded "d M Y" to "DATE_FORMAT" to respect user's configured date format preference.

Changed:

  • 6 templates: Added data-text="{{ *.start_date|date:"Y-m-d" }}" to date range cells and changed display format from |date:"d M Y" to |date:"DATE_FORMAT"
  • 1 test: Validates ISO date presence in rendered HTML

Example:

<!-- Before -->
<td>{{ project.start_date|date:"d M Y" }} – {{ project.end_date|date:"d M Y" }}</td>

<!-- After -->
<td data-text="{{ project.start_date|date:"Y-m-d" }}">{{ project.start_date|date:"DATE_FORMAT" }} – {{ project.end_date|date:"DATE_FORMAT" }}</td>

Users see dates in their configured format (e.g., "May 1, 2022" for US English or "1. Mai 2022" for German), while TableSorter sorts by "2022-05-01".

Alternate Designs

  • Extend date parser with locale mappings: Requires maintaining month names for all supported locales
  • Replace TableSorter: Too invasive for this issue alone
  • Server-side sorting only: Loses client-side interactivity

Possible Drawbacks

None identified. Changes are additive and leverage existing TableSorter functionality while respecting user preferences.

Verification Process

  • Added unit test verifying data-text attribute presence with correct ISO format
  • Code review: No issues
  • Security scan: No alerts

Manual testing requires:

  1. Set LANGUAGE_CODE = 'de' in Django settings
  2. Create projects across multiple years
  3. Visit /rolodex/projects/
  4. Click execution window column sort
  5. Verify chronological ordering
  6. Verify dates display in user's configured format

Release Notes

Fixed execution window sorting for non-English locales and dates now respect user's configured date format preference

Original prompt

This section details on the original issue you should resolve

<issue_title>Sorting Projects by Execution Window incorrect</issue_title>
<issue_description>Describe the bug
The list of projects (/rolodex/projects/) does not correctly sort projects by execution window.

To Reproduce
Steps to reproduce the behavior (assuming you have multiple projects with start dates in different years):

  1. Go to /rolodex/projects/
  2. Select All Projects
  3. Click Filter
  4. Click on the little triangle in the Execution Window column header

Expected Behavior
Projects should be sorted consistently based on the date of the first day of the project. Irrespective of the chosen date format, the projects should be sorted based on year,month and day in that order.

Example:

We are in July 2022 now, so with the following projects

  • Project A starting on 1st May 2022
  • Project B starting on 16th May 2022
  • Project C starting on 1st June 2021
    • Project C starting on 4th June 2020

sort order for most recent to least recent should be:

  • Project B
  • Project A
  • Project C
  • Project D

Screenshots
project-sorting-censored

As you can see the start dates are all over the place 2021 before 2022 , 2020 before 2021 before 2022 again.

Server Specs:

  • OS: Ubuntu 20.04 LTS
  • Docker version 20.10.17, build 100c701, Docker Compose version v2.4.1
  • Ghostwriter v3.0.0, released 22 June 2022

</issue_description>

Comments on the Issue (you are @copilot in this section)

@chrismaddalena Thanks for bringing this into an issue, @er4z0r. The screenshot helps a lot. I'm now wondering if the jQuery TableSorter has an issue with the German abbreviations. With all English month abbreviations, the sorting looks good on my end. I need to do some testing with other locales.

It might be time to look for a better solution than TableSorter.</comment_new>
<comment_new>@chrismaddalena
For better tracking, I'm lumping the issues with non-English dates under this issue. This is includes #193 and #282. We resolves #193, but these issues are all related to the date parsing tripping over non-English month names or abbreviations (e.g., Dec vs. Déc).</comment_new>


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 2 commits November 7, 2025 20:52
Co-authored-by: chrismaddalena <10526228+chrismaddalena@users.noreply.github.com>
Co-authored-by: chrismaddalena <10526228+chrismaddalena@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix sorting of projects by execution window Fix execution window sorting for non-English locales Nov 7, 2025
Copilot AI requested a review from chrismaddalena November 7, 2025 21:01
@chrismaddalena
Copy link
Collaborator

@copilot This has resolved the issue. Now that we don't need to worry about the date representation affecting sorting, we should not need to enforce that all dates appear in the d M Y format. Let's remove the |date:"d M Y" filters so that dates in tables appear using the user's configured DATE_FORMAT.

Co-authored-by: chrismaddalena <10526228+chrismaddalena@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Nov 7, 2025

@copilot This has resolved the issue. Now that we don't need to worry about the date representation affecting sorting, we should not need to enforce that all dates appear in the d M Y format. Let's ...

Changed all date filters from |date:"d M Y" to |date:"DATE_FORMAT" so dates now appear using the user's configured format preference. The data-text attribute still uses ISO format for sorting. Commit: 4aa681e

Copilot AI changed the title Fix execution window sorting for non-English locales Fix execution window sorting for non-English locales and use user's date format preference Nov 7, 2025
@codecov
Copy link

codecov bot commented Nov 7, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.39%. Comparing base (a92b20e) to head (4aa681e).
⚠️ Report is 5 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #758   +/-   ##
=======================================
  Coverage   92.38%   92.39%           
=======================================
  Files         342      342           
  Lines       19771    19779    +8     
=======================================
+ Hits        18266    18274    +8     
  Misses       1505     1505           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@chrismaddalena chrismaddalena marked this pull request as ready for review November 7, 2025 23:00
@chrismaddalena chrismaddalena merged commit cb62265 into master Nov 7, 2025
9 checks passed
@chrismaddalena chrismaddalena deleted the copilot/fix-projects-sorting-issue branch November 7, 2025 23:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants