Feature #28471

Query links for subtasks on issue page

Added by Sebastian Paluch over 3 years ago. Updated 9 months ago.

Status:ClosedStart date:
Priority:NormalDue date:
Assignee:Go MAEDA% Done:

0%

Category:Issues
Target version:4.2.0
Resolution:Fixed

Description

The header on issue page "Subtasks" list issues, in some way, with some defaults columns. It would be very helpful if the section header could be clickable link to issue queries showing those issues:

- Subtasks should link to issue query with filter parent "contains" the issue number

It would be good to have same thing for "Related issues" but there seems to be no filter allowing to show all types of relations.

query_links_for_subtasks.diff Magnifier (2.01 KB) Bernhard Rohloff, 2019-09-05 06:40

subtask_query_links.png (10.5 KB) Bernhard Rohloff, 2019-09-05 07:00

subtasks.png (92.1 KB) Marius BALTEANU, 2020-04-25 11:23

query_links_for_subtasks_marius_flavor.diff Magnifier (1.35 KB) Bernhard Rohloff, 2020-10-27 11:19

clipboard-202011051408-i3dmb.png (32.6 KB) Go MAEDA, 2020-11-05 06:11

clipboard-202011051409-nusza.png (70.5 KB) Go MAEDA, 2020-11-05 06:11

query_links_for_subtasks_marius_flavor_V2.diff Magnifier (1.34 KB) Bernhard Rohloff, 2020-11-05 15:25

0001-Include-only-visible-issues-in-subtasks-stats.patch Magnifier (7.01 KB) Marius BALTEANU, 2020-12-06 23:01

subtasks_v2.png (86.7 KB) Marius BALTEANU, 2020-12-06 23:08

0002-Unescape-href-values-before-asserting.patch Magnifier (1.94 KB) Marius BALTEANU, 2021-01-09 21:25


Related issues

Related to Redmine - Feature #35559: Query links for related issues on issue page Closed

Associated revisions

Revision 20321
Added by Go MAEDA 12 months ago

Query links for subtasks on issue page (#28471).

Patch by Bernhard Rohloff.

Revision 20718
Added by Go MAEDA 9 months ago

Some fixes for r20321:

  • Include only visible issues in subtasks stats
  • Get subtasks using only one query
  • Show all subtasks count as badge
  • Add tests

Patch by Marius BALTEANU.

History

#1 Updated by Go MAEDA over 3 years ago

It is a nice idea. Many people have requested to add more columns to the list of subtasks and related issues. It will be the solution to the request if we can move to the issues list with one click.

#2 Updated by Ewan Makepeace over 3 years ago

+1 - I would dearly love this.

#3 Updated by Ewan Makepeace about 2 years ago

Specofically whjen I am in the Roadmap I can jump from the simple list of issues in a target verson such as:

http://www.redmine.org/versions/127

To a query on either All Issues:

http://www.redmine.org/projects/redmine/issues?fixed_version_id=127&set_filter=1&status_id=%2A

Or just Open or Closed. This is hugely useful as I can then sort, group and filter to get the answers I need.

However when subtasks are grouped under a parent task there is no shortcut. I can search all issues by Parent (which is often enough) but:

  1. I would like to see this as a shortcut on the issue page (just above subtasks)
  2. I often have nested groups of tasks and so really want to see all subtasks and not just those that are a direct child of the current task.
SELECT i.* 
FROM issues i
JOIN issues p 
    ON p.root_id = i.root_id 
    AND p.lft<i.lft 
    AND p.rgt>i.rgt
WHERE p.id = @PARENT_ID;

#4 Updated by Bernhard Rohloff about 2 years ago

This patch implements Ewan's proposal. It's quite convenient to filter subtasks this way. Good idea!

#5 Updated by Bernhard Rohloff about 2 years ago

here's how it looks now...

#6 Updated by Anonymous almost 2 years ago

+1, it's a green light from me ;-)

#7 Updated by Go MAEDA almost 2 years ago

  • Target version set to Candidate for next major release

#8 Updated by Marius BALTEANU over 1 year ago

I reworked a little bit the patch proposed by Bernhard:

What do you think?

#9 Updated by Bernhard Rohloff over 1 year ago

IMHO, it looks like a nice improvement. :-)

#10 Updated by Bernhard Rohloff 12 months ago

I've added a new patch with Marius' improvements. In my opinion it would be a nice improvement to ship with 4.2.0. What do you think?

#11 Updated by Go MAEDA 12 months ago

Bernhard Rohloff wrote:

I've added a new patch with Marius' improvements. In my opinion it would be a nice improvement to ship with 4.2.0. What do you think?

Thank you for updating the patch. I think the feature is nice but the number of open/closed issues and filtered issues don't not match if subtasks has its subtasks (grand child).

See the example below. The issue has a subtask (#15 "child"). And the subtask has a subtask (#16 "grand child"). Redmine says that there are 2 open issues.

However, after you click the "2 open" link, the issues list displays only 1 issue.

#12 Updated by Go MAEDA 12 months ago

Maybe #28471#note-11 can be fixed by using "contains" operator instead of "is" operator.

#13 Updated by Bernhard Rohloff 12 months ago

Thank you Maeda san for testing my patch. Here's a slightly better version of my previous patch including your suggestion. It's indeed better to do it this way. :-)

#14 Updated by Go MAEDA 12 months ago

  • Target version changed from Candidate for next major release to 4.2.0

Bernhard Rohloff wrote:

Thank you Maeda san for testing my patch. Here's a slightly better version of my previous patch including your suggestion. It's indeed better to do it this way. :-)

Thank you for updating the patch. The patch now looks good. Setting the target to 4.2.0.

#15 Updated by Go MAEDA 12 months ago

  • Subject changed from Make "Subtasks" section headers a links to issue query to Query links for subtasks on issue page
  • Status changed from New to Closed
  • Assignee set to Go MAEDA
  • Resolution set to Fixed

Committed the patch. Thank you for your contribution.

#16 Updated by Marius BALTEANU 12 months ago

  • Status changed from Closed to Reopened

We should add some functional tests.

#17 Updated by Bernhard Rohloff 11 months ago

Here's some test code. Since I'm not very used to rails testing, I'm not sure if it's sufficient enough.

Index: test/functional/issues_controller_test.rb
===================================================================
--- test/functional/issues_controller_test.rb   (Revision 20333)
+++ test/functional/issues_controller_test.rb   (Arbeitskopie)
@@ -2299,6 +2299,49 @@
     end
   end

+  def test_show_should_show_subtasks_links_to_queries
+    child = Issue.
+      create!(
+        :project_id => 1, :author_id => 1, :tracker_id => 1,
+        :parent_issue_id => 1, :subject => 'Child issue'
+      )
+    get(:show, :params => {:id => 1})
+    assert_response :success
+    assert_select 'div#issue_tree' do
+      assert_select 'p' do
+        assert_select 'a', :text => '1 issue'
+        assert_select 'a', :text => '1 open'
+      end
+    end
+    Issue.
+      create!(
+        :project_id => 1, :author_id => 1, :tracker_id => 1,
+        :parent_issue_id => child.id, :subject => 'Child of child'
+    )
+    get(:show, :params => {:id => 1})
+    assert_response :success
+    assert_select 'div#issue_tree' do
+      assert_select 'p' do
+        assert_select 'a', :text => '2 issues'
+        assert_select 'a', :text => '2 open'
+      end
+    end
+    Issue.
+      create!(
+        :project_id => 1, :author_id => 1, :tracker_id => 1,
+        :parent_issue_id => 1, :status_id => 5, :subject => 'Closed child issue'
+    )
+    get(:show, :params => {:id => 1})
+    assert_response :success
+    assert_select 'div#issue_tree' do
+      assert_select 'p' do
+        assert_select 'a', :text => '3 issues'
+        assert_select 'a', :text => '2 open'
+        assert_select 'a', :text => '1 closed'
+      end
+    end
+  end
+
   def test_show_should_list_parents
     issue = Issue.
               create!(

#18 Updated by Marius BALTEANU 11 months ago

  • File subtasks.png added
  • File 0001-Include-only-visible-issues-in-subtasks-stats.patch added

Thanks Bernhard for the tests.

Reviewing them, I found out that the current implementation has two issues:
  • issue visibility is not checked
  • there are quite many queries to get the subtasks
I took the liberty to rewrite a little bit the current implementation in order to:
  • fix the issue visibility
  • get subtasks using one query by grouping them
  • move the entire logic from view to helper
  • change the layout to show the subtasks count as badge
  • finalise the tests

#19 Updated by Marius BALTEANU 11 months ago

  • Assignee changed from Go MAEDA to Marius BALTEANU

Some tests fail on Postgres and Sql server.

#20 Updated by Marius BALTEANU 11 months ago

  • File deleted (subtasks.png)

#21 Updated by Marius BALTEANU 11 months ago

  • File deleted (0001-Include-only-visible-issues-in-subtasks-stats.patch)

#22 Updated by Marius BALTEANU 11 months ago

I've fixed the issue by casting the values returned from the database to boolean. Now the tests pass on all three database types: https://gitlab.com/redmine-org/redmine/-/pipelines/225982433

#23 Updated by Marius BALTEANU 11 months ago

#24 Updated by Bernhard Rohloff 11 months ago

  • Assignee set to Marius BALTEANU

Thank you Marius for reviewing and improving my work. I really like the badge style.

BTW my implementation was shamelessly copied from the versions/_overview partial found in the roadmap. So we may have room for improvements over there, too.

#25 Updated by Bernhard Rohloff 11 months ago

  • Assignee deleted (Marius BALTEANU)

#26 Updated by Go MAEDA 10 months ago

Marius BALTEANU wrote:

I've fixed the issue by casting the values returned from the database to boolean. Now the tests pass on all three database types: https://gitlab.com/redmine-org/redmine/-/pipelines/225982433

Thank you for posting the 0001-Include-only-visible-issues-in-subtasks-stats.patch but the test fails if you run it with Ruby 2.4.

$ ruby test/functional/issues_controller_test.rb 
Run options: --seed 49701

# Running:

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

Failure:
IssuesControllerTest#test_show_should_show_subtasks_stats [test/functional/issues_controller_test.rb:2354]:
Expected at least 1 element matching "span.open a[href="/issues?parent_id=~1&set_filter=true&status_id=o"]", found 0..
Expected 0 to be >= 1.

bin/rails test test/functional/issues_controller_test.rb:2343

....................................S..............................................................................................................................................S.....................................................................................................................................................S....................................F

Failure:
IssuesControllerTest#test_show_subtasks_stats_should_not_link_if_issue_has_zero_open_or_closed_subtasks [test/functional/issues_controller_test.rb:2367]:
Expected at least 1 element matching "span.open a[href="/issues?parent_id=~1&set_filter=true&status_id=o"]", found 0..
Expected 0 to be >= 1.

bin/rails test test/functional/issues_controller_test.rb:2361

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

This is because issue_path method returns a different value depending on the version of Ruby.

# Ruby 2.4
(byebug) issues_path(parent_id: "~1", set_filter: true)
"/issues?parent_id=%7E1&set_filter=true" 

# Ruby 2.5 or later
(byebug) issues_path(parent_id: "~1", set_filter: true)
"/issues?parent_id=~1&set_filter=true" 

#27 Updated by Marius BALTEANU 10 months ago

  • Assignee set to Marius BALTEANU

#28 Updated by Marius BALTEANU 10 months ago

Can you try on Ruby 2.4 using the attached patch, please? It should pass now. If still doesn't, I will create a local environment with 2.4.

#29 Updated by Go MAEDA 10 months ago

  • Assignee changed from Go MAEDA to Marius BALTEANU

Marius BALTEANU wrote:

Can you try on Ruby 2.4 using the attached patch, please? It should pass now.

Thank you, I confirmed that there is no test failure with 2.4.

#30 Updated by Go MAEDA 9 months ago

  • Assignee changed from Marius BALTEANU to Go MAEDA

#31 Updated by Go MAEDA 9 months ago

  • Status changed from Reopened to Closed

#32 Updated by Go MAEDA about 1 month ago

  • Related to Feature #35559: Query links for related issues on issue page added

Also available in: Atom PDF