プロジェクト

全般

プロフィール

Vote #64758

未完了

Sort time entries by name, not ID

Admin Redmine さんがほぼ2年前に追加. ほぼ2年前に更新.

ステータス:
New
優先度:
通常
担当者:
-
カテゴリ:
Time tracking_13
開始日:
2009/02/26
期日:
進捗率:

90%

予定工数:
category_id:
13
version_id:
32
issue_org_id:
2848
author_id:
2928
assigned_to_id:
0
comments:
12
status_id:
1
tracker_id:
2
plus1:
0
affected_version:
closed_on:
affected_version_id:
ステータス-->[New]

説明

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.


journals

I tried adding an order clause to the query, but found that sql_group_by talks about IDs, not names. Hrm...

<pre>
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)
</pre>
--------------------------------------------------------------------------------
The attached patch should work. Wouldn't mind another eye on it though.
--------------------------------------------------------------------------------
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.
--------------------------------------------------------------------------------
Mm. Agreed on refactoring the sorting into the controller. I'll take a look at that today.
--------------------------------------------------------------------------------
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.
--------------------------------------------------------------------------------
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?
--------------------------------------------------------------------------------
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
--------------------------------------------------------------------------------
Ah that's good to know. Then only problem number 2 (the sorting order of the list format custom fields) remains.
--------------------------------------------------------------------------------
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.
--------------------------------------------------------------------------------
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.
--------------------------------------------------------------------------------
Fixed the sort order of activities that work on the trunk(r21371).

--------------------------------------------------------------------------------

--------------------------------------------------------------------------------

Admin Redmine さんがほぼ2年前に更新

  • カテゴリTime tracking_13 にセット
  • 対象バージョンCandidate for next major release_32 にセット

他の形式にエクスポート: Atom PDF

いいね!0
いいね!0