Feature #2848
openSort time entries by name, not ID
90%
Description
Go to /time_entries/report and filter by project or member. Both result in a list sorted by the row's respective ID, not by it's name.
Files
Updated by Brad Beattie almost 16 years ago
I tried adding an order clause to the query, but found that sql_group_by talks about IDs, not names. Hrm...
Index: timelog_controller.rb =================================================================== --- timelog_controller.rb (revision 2521) +++ timelog_controller.rb (working copy) @@ -90,6 +90,7 @@ sql << " (%s) AND" % Project.allowed_to_condition(User.current, :view_time_entries) sql << " (spent_on BETWEEN '%s' AND '%s')" % [ActiveRecord::Base.connection.quoted_date(@from.to_time), ActiveRecord::Base.connection.quoted_date(@to.to_time)] sql << " GROUP BY #{sql_group_by}, tyear, tmonth, tweek, spent_on" + sql << " ORDER BY #{sql_group_by}" @hours = ActiveRecord::Base.connection.select_all(sql)
Updated by Brad Beattie almost 16 years ago
- File timelog_controller.rb.patch timelog_controller.rb.patch added
- % Done changed from 0 to 80
The attached patch should work. Wouldn't mind another eye on it though.
Updated by Jean-Philippe Lang almost 16 years ago
Your patch seems to work for projects and users but not for the other criteria.
Another option would be to the sort the query results in the app. That would save extra joins.
Updated by Brad Beattie almost 16 years ago
- % Done changed from 80 to 30
Mm. Agreed on refactoring the sorting into the controller. I'll take a look at that today.
Updated by Brad Beattie almost 16 years ago
- File _report_criteria.rhtml.patch _report_criteria.rhtml.patch added
- % Done changed from 30 to 90
Jean-Philippe Lang wrote:
Your patch seems to work for projects and users but not for the other criteria.
Another option would be to the sort the query results in the app. That would save extra joins.
This attached patch should address both concerns.
Updated by Kevin Fischer over 4 years ago
Last week we were looking at this long existing issue with a few people to create an up-to-date patch that covers all necessary cases.
We came to the conclusion that it is first necessary to clarify the right way to implement this issue.
As we can see from the current implementation ( https://github.com/redmine/redmine/blob/master/lib/redmine/helpers/time_report.rb#L49-L59 ), no order is specified for the data shown in the Report Tab, which results in data being returned in order of insertion/primary key. This order can neither be changed via settings/UI nor is it based on anything you can see anywhere in Redmine (like the name/title or a specified order).
The following category columns are available in the Time Report. With each column I write a suggested sorting order to be implemented for this patch.
- Project: by name
- Status: by position (Set in Administration > Issue Statuses)
- Version: by name
- Issue Category: by name
- User: by last name and then by first name
- Tracker: by position (Set in Administration > Trackers)
- Activities: by position (Set in Administration > Enumerations)
- Issue: by ID
- List format custom fields: Alphabetically
- Bool format custom fields: true first, then false
Above choices were made with a solution in mind, that would only add a fitting ORDER SQL condition to the existing code (similar to/extending Brad Beattie's patch).
I can, however, see at least two possible reasons why such a solution might not be good enough:
- User name display depends on Redmine settings. If the sort order should be based on the user name display settings, an SQL only solution becomes impossible
- A similar problem exists for list format custom fields. The best solution would probably be to sort the rows in the order of possible values, but since possible values are saved as a serialized JSON array, using their order with SQL is not possible.
Therefore, it might be necessary to implement a custom sorting solution in Ruby.
These are our thoughts so far, what do you think?
Updated by Pavel Rosický over 4 years ago
1. there's a way to sort user names according to display settings, see https://github.com/redmine/redmine/blob/e93febfda23b5fdc17d0bc1ad540b3ae926488c1/app/models/principal.rb#L115
Updated by Kevin Fischer over 4 years ago
Ah that's good to know. Then only problem number 2 (the sorting order of the list format custom fields) remains.
Updated by Yuichi HARADA over 3 years ago
- File 2848.patch 2848.patch added
Kevin Fischer wrote:
The following category columns are available in the Time Report. With each column I write a suggested sorting order to be implemented for this patch.
- Project: by name
- Status: by position (Set in Administration > Issue Statuses)
- Version: by name
- Issue Category: by name
- User: by last name and then by first name
- Tracker: by position (Set in Administration > Trackers)
- Activities: by position (Set in Administration > Enumerations)
- Issue: by ID
- List format custom fields: Alphabetically
- Bool format custom fields: true first, then false
I created a patch that displays each column in the above order.
However, List format & Bool format custom fields columns are displayed in the order of the options in the custom field select box.
Any feedback is welcome.
Updated by Yuichi HARADA about 3 years ago
- File 2848-with-test.patch 2848-with-test.patch added
Yuichi HARADA wrote:
Kevin Fischer wrote:
The following category columns are available in the Time Report. With each column I write a suggested sorting order to be implemented for this patch.
- Project: by name
- Status: by position (Set in Administration > Issue Statuses)
- Version: by name
- Issue Category: by name
- User: by last name and then by first name
- Tracker: by position (Set in Administration > Trackers)
- Activities: by position (Set in Administration > Enumerations)
- Issue: by ID
- List format custom fields: Alphabetically
- Bool format custom fields: true first, then false
I created a patch that displays each column in the above order.
However, List format & Bool format custom fields columns are displayed in the order of the options in the custom field select box.
I created tests. I attach a patch with tests.
Updated by Yuichi HARADA almost 3 years ago
- File 2848-with-test-v2.patch 2848-with-test-v2.patch added
Fixed the sort order of activities that work on the trunk(r21371).
Updated by Go MAEDA almost 3 years ago
- Target version set to Candidate for next major release