From dbb08d8e2d02a7e4847819814d1bc15672a159b1 Mon Sep 17 00:00:00 2001 From: Egbert van der Wal Date: Tue, 3 Jun 2014 18:17:00 +0200 Subject: [PATCH] some more bug fixes to configuration and getting issues --- README.md | 1 + app/controllers/planning_controller.rb | 31 ++++++++++++++++++-------- init.rb | 2 +- 3 files changed, 24 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 6152ac0..f1c51cc 100644 --- a/README.md +++ b/README.md @@ -79,6 +79,7 @@ When you hit the left or right edge of the rectangles the cursor will indicate t * Export chart to SVG # Version log +* 0.7.5.1: Jun 3, 2014. Update on getting all related issues and another fix on configuration * 0.7.5: Jun 3, 2014. Fix issue #14. Also improved performance of relation retrieval and will now load all related issues such as parents. Without this, the planning cannot be fully done properly. * 0.7.4: May 27, 2014. Add zoom-in and zoom-out buttons * 0.7.3: May 27, 2014. Fix placement of tooltip in fullscreen and fix tooltip not showing when no description is set. diff --git a/app/controllers/planning_controller.rb b/app/controllers/planning_controller.rb index 48aa7a9..4e8d91d 100644 --- a/app/controllers/planning_controller.rb +++ b/app/controllers/planning_controller.rb @@ -159,30 +159,43 @@ def issues iterations = 1 while true - to_retrieve = Set.new + # List of new issues to retrieve + issue_retrieve = Set.new + + # List of new relations to retrieve + relation_retrieve = Set.new + + # Do a first pass to add all retrieved issues and add their id to the list of relations to fetch issues.each do |issue| add_issue(issue) + relation_retrieve.add(issue[:id]) + end + # Do a second pass to add unseen parent issues to the new list. This is + # to avoid additional queries since in the first pass, the order may be + # such that the child tasks are seen before their parents + issues.each do |issue| next unless issue.parent_issue_id - to_retrieve.add(issue.parent_issue_id) unless @issue_ids.include?(issue.parent_issue_id) + issue_retrieve.add(issue.parent_issue_id) unless @issue_ids.include?(issue.parent_issue_id) end - # On the first iteration, get relations of all issues seen so far. - # On later iterations only retrieve of the newly loaded issues. - relation_retrieve = iterations == 1 ? @issue_ids : to_retrieve + # Get relations for newly loaded issues + logger.error(relation_retrieve.to_a) relations = IssueRelation.where("issue_from_id IN (:ids) OR issue_to_id IN (:ids)", :ids => relation_retrieve) relations.each do |relation| add_relation(relation) + # We should avoid fetching issues just because they are related / + # duplicated or copied, since those do not impede planning. next unless ['precedes', 'blocks'].include?(relation.relation_type) - to_retrieve.add(relation[:from]) unless @issue_ids.include?(relation[:from]) - to_retrieve.add(relation[:to]) unless @issue_ids.include?(relation[:to]) + issue_retrieve.add(relation[:issue_from_id]) unless @issue_ids.include?(relation[:issue_from_id]) + issue_retrieve.add(relation[:issue_to_id]) unless @issue_ids.include?(relation[:issue_to_id]) end # See if we're done - break if to_retrieve.size == 0 + break if issue_retrieve.size == 0 # Retrieve all new issues iterations += 1 - issues = Issue.where("id IN (:ids) OR parent_id IN (:ids)", :ids => to_retrieve) + issues = Issue.where("id IN (:ids) OR parent_id IN (:ids)", :ids => issue_retrieve) end logger.info("Retrieved all issues and relations in #{iterations} iteration(s)") diff --git a/init.rb b/init.rb index 1badfd1..7e34a71 100644 --- a/init.rb +++ b/init.rb @@ -27,7 +27,7 @@ description 'Offers a UI tailored for planning projects by dragging, dropping ' + 'and resizing issues and by adding and editing relations and ' + 'providing critical path analysis' - version '0.7.5' + version '0.7.5.1' if respond_to?(:url) url 'https://github.com/MadEgg/redmine_planning'