Skip to content

Commit

Permalink
some more bug fixes to configuration and getting issues
Browse files Browse the repository at this point in the history
  • Loading branch information
EgbertW committed Jun 3, 2014
1 parent 05ff254 commit dbb08d8
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 10 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
31 changes: 22 additions & 9 deletions app/controllers/planning_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)")

Expand Down
2 changes: 1 addition & 1 deletion init.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down

0 comments on commit dbb08d8

Please sign in to comment.