Patch #32436

Add support for grouping by issue on timelog view

Added by Kouhei Sutou 11 months ago. Updated 10 months ago.

Status:ClosedStart date:
Priority:NormalDue date:
Assignee:Jean-Philippe Lang% Done:

0%

Category:Time tracking
Target version:4.2.0

Description

We can view how many hours we spend for the target issue and its child issues in timelog view (/projects/${PROJECT}/time_entries?set_filter=1&f[]=issue_id&op[issue_id]=~&v[issue_id][]=${ISSUE_ID}).

If we can group by issue, we can confirm how many hours we spend for each issue in the view easily. It's useful to analysis which issue was heavy.

The attached patch implements this feature.

timelog-issue-groupable.diff Magnifier (1.82 KB) Kouhei Sutou, 2019-11-08 08:42

spent-time-group-by-issue@2x.png (68.5 KB) Go MAEDA, 2019-11-09 10:47

Associated revisions

Revision 19063
Added by Jean-Philippe Lang 11 months ago

Add support for grouping by issue on timelog view (#32436).

Patch by Kouhei Sutou.

Revision 19064
Added by Jean-Philippe Lang 11 months ago

Merged r19063 to 4.1-stable (#32436).

Revision 19092
Added by Jean-Philippe Lang 10 months ago

Fixes the assertion so that it doesn't rely on the display order (#32436).

Patch by Kouhei Sutou.

History

#1 Updated by Go MAEDA 11 months ago

This is a nice improvement. Setting the target version to 4.1.0.

#2 Updated by Jean-Philippe Lang 11 months ago

  • Status changed from New to Closed
  • Assignee set to Jean-Philippe Lang

Committed, thanks.

#3 Updated by Marius BALTEANU 11 months ago

  • Status changed from Closed to Reopened

A test fails on Postgresql (because of the #32404):


Failure:
TimelogControllerTest#test_index_grouped_by_issue [/builds/redmine-org/redmine/test/functional/timelog_controller_test.rb:1429]:
--- expected
+++ actual
@@ -1 +1 @@
-"Bug #1: Cannot print recipes" 
+"Bug #3: Error 281 when updating a recipe" 

bin/rails test test/functional/timelog_controller_test.rb:1422

Until we fix that issue, I think it is good enough to rewrite the test added in r19063 as following:

index 9c0b958b9..a362e769d 100644
--- a/test/functional/timelog_controller_test.rb
+++ b/test/functional/timelog_controller_test.rb
@@ -1426,10 +1426,6 @@ class TimelogControllerTest < Redmine::ControllerTest
       }
     assert_response :success

-    assert_select 'tr.group span.name' do |elements|
-      target_element = elements[1]
-      assert_equal "Bug #1: Cannot print recipes", target_element.text
-      assert_select target_element, '+ span.count', :text => '2'
-    end
+    assert_select 'tr.group span.name', :text => "Bug #1: Cannot print recipes" 
   end
 end

#4 Updated by Kouhei Sutou 11 months ago

Does the following also work on PostgreSQL?

diff --git a/test/functional/timelog_controller_test.rb b/test/functional/timelog_controller_test.rb
index 9c0b958b99..d2f6c94640 100644
--- a/test/functional/timelog_controller_test.rb
+++ b/test/functional/timelog_controller_test.rb
@@ -1426,10 +1426,8 @@ class TimelogControllerTest < Redmine::ControllerTest
       }
     assert_response :success

-    assert_select 'tr.group span.name' do |elements|
-      target_element = elements[1]
-      assert_equal "Bug #1: Cannot print recipes", target_element.text
-      assert_select target_element, '+ span.count', :text => '2'
+    assert_select 'tr.group span.name', :text => 'Bug #1: Cannot print recipes' do
+      assert_select '+ span.count', :text => '2'
     end
   end
 end

#5 Updated by Marius BALTEANU 10 months ago

Kouhei Sutou wrote:

Does the following also work on PostgreSQL?

[...]

From my point of view, it is not so important to validate the group count number in this case.

#6 Updated by Kouhei Sutou 10 months ago

I don't have strong opinion for this. I'm OK without assertion for count.

#7 Updated by Jean-Philippe Lang 10 months ago

  • Target version changed from 4.1.0 to 4.2.0

#8 Updated by Yuichi HARADA 10 months ago

Kouhei Sutou wrote:

Does the following also work on PostgreSQL?

[...]

TimelogControllerTest passed after applying the #32436-4 patch.

-- Before: trunk(r19089) --

$ RAILS_ENV=test bundle exec rake db:migrate:reset

$ RAILS_ENV=test bundle exec rake test TEST=test/functional/timelog_controller_test.rb
Run options: --seed 27908

# Running:

............................................................................................F

Failure:
TimelogControllerTest#test_index_grouped_by_issue [test/functional/timelog_controller_test.rb:1429]:
--- expected
+++ actual
@@ -1 +1 @@
-"Bug #1: Cannot print recipes" 
+"Bug #3: Error 281 when updating a recipe" 

bin/rails test test/functional/timelog_controller_test.rb:1422

..........

Finished in 19.580212s, 5.2604 runs/s, 16.1387 assertions/s.
103 runs, 316 assertions, 1 failures, 0 errors, 0 skips

-- After: Apply #32436-4 patch --

$ RAILS_ENV=test bundle exec rake db:migrate:reset

$ RAILS_ENV=test bundle exec rake test TEST=test/functional/timelog_controller_test.rb
Run options: --seed 52670

# Running:

.......................................................................................................

Finished in 21.153100s, 4.8693 runs/s, 14.9387 assertions/s.
103 runs, 316 assertions, 0 failures, 0 errors, 0 skips

#9 Updated by Jean-Philippe Lang 10 months ago

  • Status changed from Reopened to Closed

Kouhei Sutou wrote:

Does the following also work on PostgreSQL?

Thanks, the assertion is better like this as it doesn't rely on the display order. It's committed.

Also available in: Atom PDF