Project

General

Profile

Actions

Feature #28471

closed

Query links for subtasks on issue page

Added by Sebastian Paluch over 6 years ago. Updated almost 4 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Issues
Target version:
Start date:
Due date:
% Done:

0%

Estimated time:
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.


Files


Related issues

Related to Redmine - Feature #35559: Query links for related issues on issue pageClosedGo MAEDA

Actions
Actions #1

Updated by Go MAEDA over 6 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.

Actions #2

Updated by Ewan Makepeace over 6 years ago

+1 - I would dearly love this.

Actions #3

Updated by Ewan Makepeace about 5 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;
Actions #4

Updated by Bernhard Rohloff about 5 years ago

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

Actions #5

Updated by Bernhard Rohloff about 5 years ago

here's how it looks now...

Actions #6

Updated by Anonymous almost 5 years ago

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

Actions #7

Updated by Go MAEDA almost 5 years ago

  • Target version set to Candidate for next major release
Actions #8

Updated by Marius BĂLTEANU over 4 years ago

I reworked a little bit the patch proposed by Bernhard:

What do you think?

Actions #9

Updated by Bernhard Rohloff over 4 years ago

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

Actions #10

Updated by Bernhard Rohloff about 4 years 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?

Actions #11

Updated by Go MAEDA almost 4 years 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.

Actions #12

Updated by Go MAEDA almost 4 years ago

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

Actions #13

Updated by Bernhard Rohloff almost 4 years 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. :-)

Actions #14

Updated by Go MAEDA almost 4 years 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.

Actions #15

Updated by Go MAEDA almost 4 years 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.

Actions #16

Updated by Marius BĂLTEANU almost 4 years ago

  • Status changed from Closed to Reopened

We should add some functional tests.

Actions #17

Updated by Bernhard Rohloff almost 4 years 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!(

Actions #18

Updated by Marius BĂLTEANU almost 4 years 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

Actions #19

Updated by Marius BĂLTEANU almost 4 years ago

  • Assignee changed from Go MAEDA to Marius BĂLTEANU

Some tests fail on Postgres and Sql server.

Actions #20

Updated by Marius BĂLTEANU almost 4 years ago

  • File deleted (subtasks.png)
Actions #21

Updated by Marius BĂLTEANU almost 4 years ago

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

Updated by Marius BĂLTEANU almost 4 years 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

Actions #24

Updated by Bernhard Rohloff almost 4 years ago

  • Assignee set to Marius BĂLTEANU

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.

Actions #25

Updated by Bernhard Rohloff almost 4 years ago

  • Assignee deleted (Marius BĂLTEANU)
Actions #26

Updated by Go MAEDA almost 4 years 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" 
Actions #27

Updated by Marius BĂLTEANU almost 4 years ago

  • Assignee set to Marius BĂLTEANU
Actions #28

Updated by Marius BĂLTEANU almost 4 years 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.

Actions #29

Updated by Go MAEDA almost 4 years ago

  • Assignee changed from Go MAEDA to Marius BĂLTEANU

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.

Actions #30

Updated by Go MAEDA almost 4 years ago

  • Assignee changed from Marius BĂLTEANU to Go MAEDA
Actions #31

Updated by Go MAEDA almost 4 years ago

  • Status changed from Reopened to Closed
Actions #32

Updated by Go MAEDA about 3 years ago

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

Also available in: Atom PDF