Defect #34297

Subprojects issues are not displayed on main project when all subprojects are closed

Added by huijun Kim 6 months ago. Updated 4 months ago.

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

0%

Category:Issues list
Target version:4.0.8
Resolution:Fixed Affected version:4.1.1

Description

No issues are displayed on issue page

parent project (open)
  - subproject1 (closed)
  - subproject2 (closed)

It shows sub1, sub2 issues.

parent project (open)
  - subproject1 (closed)
  - subproject2 (open)

fixed-34297.patch Magnifier (5.24 KB) Yuichi HARADA, 2020-12-03 09:19

34297-v2.patch Magnifier (3.15 KB) Go MAEDA, 2020-12-23 12:31


Related issues

Related to Redmine - Defect #34375: "is not" operator for Subproject filter incorrectly exclu... Closed

Associated revisions

Revision 20693
Added by Go MAEDA 4 months ago

Subprojects issues are not displayed on main project when all subprojects are closed (#34297).

Patch by Yuichi HARADA and Go MAEDA.

Revision 20694
Added by Go MAEDA 4 months ago

Make sure that "is not" operator for Subproject filter does not exclude closed subprojects (#34375).

The issue has been fixed in r20693 along with #34297.

Revision 20695
Added by Go MAEDA 4 months ago

Merged r20693 from trunk to 4.1-stable (#34297).

Revision 20696
Added by Go MAEDA 4 months ago

Merged r20693 from trunk to 4.0-stable (#34297).

History

#1 Updated by Go MAEDA 6 months ago

  • Status changed from New to Confirmed

I have confirmed the reported behavior. If there are one or more open subprojects, issues in closed subprojects are visible in a parent project's issues list. However, if all subprojects are closed, all issues from subprojects are invisible.

#2 Updated by Go MAEDA 5 months ago

  • Subject changed from The issue is not visible when closing all subprojects. to Subprojects issues are not displayed on main project when all subprojects are closed

#3 Updated by Go MAEDA 5 months ago

  • Related to Defect #34375: "is not" operator for Subproject filter incorrectly excludes closed subprojects added

#4 Updated by Yuichi HARADA 5 months ago

Go MAEDA wrote:

I have confirmed the reported behavior. If there are one or more open subprojects, issues in closed subprojects are visible in a parent project's issues list. However, if all subprojects are closed, all issues from subprojects are invisible.

I created a patch. I fix to show subprojects issues even if all subprojects are closed.

#5 Updated by Go MAEDA 5 months ago

  • Target version set to Candidate for next major release

#6 Updated by Go MAEDA 5 months ago

Yuichi HARADA wrote:

I created a patch. I fix to show subprojects issues even if all subprojects are closed.

Thank you for posting the patch.

What do you think about the following approach? The number of lines to be changed is minimal, and also fixes #34375.

diff --git a/app/models/query.rb b/app/models/query.rb
index 18f1b135b..8ed09579d 100644
--- a/app/models/query.rb
+++ b/app/models/query.rb
@@ -898,10 +898,10 @@ class Query < ActiveRecord::Base

   def project_statement
     project_clauses = []
-    active_subprojects_ids = []
+    non_archived_subprojects_ids = []

-    active_subprojects_ids = project.descendants.active.map(&:id) if project
-    if active_subprojects_ids.any?
+    non_archived_subprojects_ids = project.descendants.where.not(status: Project::STATUS_ARCHIVED).ids if project
+    if non_archived_subprojects_ids.any?
       if has_filter?("subproject_id")
         case operator_for("subproject_id")
         when '='
@@ -910,7 +910,7 @@ class Query < ActiveRecord::Base
           project_clauses << "#{Project.table_name}.id IN (%s)" % ids.join(',')
         when '!'
           # exclude the selected subprojects
-          ids = [project.id] + active_subprojects_ids - values_for("subproject_id").map(&:to_i)
+          ids = [project.id] + non_archived_subprojects_ids - values_for("subproject_id").map(&:to_i)
           project_clauses << "#{Project.table_name}.id IN (%s)" % ids.join(',')
         when '!*'
           # main project only

#7 Updated by Yuichi HARADA 5 months ago

Go MAEDA wrote:

What do you think about the following approach? The number of lines to be changed is minimal, and also fixes #34375.

[...]

That's great. I have confirmed that #34375 is also improved with minimal changes.

#8 Updated by Go MAEDA 5 months ago

Yuichi HARADA wrote:

Go MAEDA wrote:

What do you think about the following approach? The number of lines to be changed is minimal, and also fixes #34375.

[...]

That's great. I have confirmed that #34375 is also improved with minimal changes.

Thank you for checking the code. I have updated the patch:

#9 Updated by Go MAEDA 4 months ago

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

Setting the target version to 4.0.8.

#10 Updated by Go MAEDA 4 months ago

  • Status changed from Confirmed to Resolved
  • Assignee set to Go MAEDA

Committed the patch.

#11 Updated by Go MAEDA 4 months ago

  • Status changed from Resolved to Closed
  • Resolution set to Fixed

Also available in: Atom PDF