@@ -854,10 +854,8 class Issue < ActiveRecord::Base | |||
|
854 | 854 | end |
|
855 | 855 | |
|
856 | 856 | # Returns all the other issues that depend on the issue |
|
857 | # The algorithm is a modified breadth first search (bfs) | |
|
857 | 858 | def all_dependent_issues(except=[]) |
|
858 | ||
|
859 | # The algorithm as a modified bread first search (bfs) | |
|
860 | ||
|
861 | 859 | # The found dependencies |
|
862 | 860 | dependencies = [] |
|
863 | 861 | |
@@ -879,77 +877,77 class Issue < ActiveRecord::Base | |||
|
879 | 877 | eALL_PROCESSED = 5 # The issue and all its children, its parent and its related issues have been |
|
880 | 878 | # added as dependent issues. It needs no further processing. |
|
881 | 879 | |
|
882 |
issue |
|
|
880 | issue_status = Hash.new(eNOT_DISCOVERED) | |
|
883 | 881 | |
|
884 | 882 | # The queue |
|
885 | 883 | queue = [] |
|
886 | 884 | |
|
887 | 885 | # Initialize the bfs, add start node (self) to the queue |
|
888 | 886 | queue << self |
|
889 |
issue |
|
|
887 | issue_status[self] = ePROCESS_ALL | |
|
890 | 888 | |
|
891 | 889 | while (!queue.empty?) do |
|
892 | 890 | |
|
893 |
current |
|
|
894 |
current |
|
|
891 | current_issue = queue.shift | |
|
892 | current_issue_status = issue_status[current_issue] | |
|
895 | 893 | |
|
896 |
dependencies << current |
|
|
894 | dependencies << current_issue | |
|
897 | 895 | |
|
898 | 896 | # Add parent to queue, if not already in it. |
|
899 |
parent = current |
|
|
900 |
parentStatus = issue |
|
|
897 | parent = current_issue.parent | |
|
898 | parentStatus = issue_status[parent] | |
|
901 | 899 | |
|
902 | 900 | if parent && (parentStatus == eNOT_DISCOVERED) && !except.include?(parent) then |
|
903 | 901 | |
|
904 | 902 | queue << parent |
|
905 |
issue |
|
|
903 | issue_status[parent] = ePROCESS_RELATIONS_ONLY | |
|
906 | 904 | |
|
907 | 905 | end |
|
908 | 906 | |
|
909 | 907 | # Add children to queue, but only if they are not already in it and |
|
910 | 908 | # the children of the current node need to be processed. |
|
911 |
if current |
|
|
909 | if current_issue.children && (current_issue_status == ePROCESS_CHILDREN_ONLY || current_issue_status == ePROCESS_ALL) then | |
|
912 | 910 | |
|
913 |
current |
|
|
911 | current_issue.children.each do |child| | |
|
914 | 912 | |
|
915 |
if (issue |
|
|
913 | if (issue_status[child] == eNOT_DISCOVERED) && !except.include?(child) | |
|
916 | 914 | queue << child |
|
917 |
issue |
|
|
915 | issue_status[child] = ePROCESS_ALL | |
|
918 | 916 | |
|
919 |
elsif (issue |
|
|
917 | elsif (issue_status[child] == eRELATIONS_PROCESSED) && !except.include?(child) | |
|
920 | 918 | queue << child |
|
921 |
issue |
|
|
919 | issue_status[child] = ePROCESS_CHILDREN_ONLY | |
|
922 | 920 | |
|
923 |
elsif (issue |
|
|
921 | elsif (issue_status[child] == ePROCESS_RELATIONS_ONLY) && !except.include?(child) | |
|
924 | 922 | queue << child |
|
925 |
issue |
|
|
923 | issue_status[child] = ePROCESS_ALL | |
|
926 | 924 | end |
|
927 | 925 | end |
|
928 | 926 | end |
|
929 | 927 | |
|
930 | 928 | # Add related issues to the queue, if they are not already in it. |
|
931 |
current |
|
|
929 | current_issue.relations_from.map(&:issue_to).each do |relatedIssue| | |
|
932 | 930 | |
|
933 |
if (issue |
|
|
931 | if (issue_status[relatedIssue] == eNOT_DISCOVERED) && !except.include?(relatedIssue) then | |
|
934 | 932 | queue << relatedIssue |
|
935 |
issue |
|
|
933 | issue_status[relatedIssue] = ePROCESS_ALL | |
|
936 | 934 | |
|
937 |
elsif (issue |
|
|
935 | elsif (issue_status[relatedIssue] == eRELATIONS_PROCESSED) && !except.include?(relatedIssue) then | |
|
938 | 936 | queue << relatedIssue |
|
939 |
issue |
|
|
937 | issue_status[relatedIssue] = ePROCESS_CHILDREN_ONLY | |
|
940 | 938 | |
|
941 |
elsif (issue |
|
|
939 | elsif (issue_status[relatedIssue] == ePROCESS_RELATIONS_ONLY) && !except.include?(relatedIssue) then | |
|
942 | 940 | queue << relatedIssue |
|
943 |
issue |
|
|
941 | issue_status[relatedIssue] = ePROCESS_ALL | |
|
944 | 942 | end |
|
945 | 943 | end |
|
946 | 944 | |
|
947 | 945 | # Set new status for current issue |
|
948 |
if (current |
|
|
949 |
issue |
|
|
946 | if (current_issue_status == ePROCESS_ALL) || (current_issue_status == ePROCESS_CHILDREN_ONLY) then | |
|
947 | issue_status[current_issue] = eALL_PROCESSED | |
|
950 | 948 | |
|
951 |
elsif (current |
|
|
952 |
issue |
|
|
949 | elsif (current_issue_status == ePROCESS_RELATIONS_ONLY) then | |
|
950 | issue_status[current_issue] = eRELATIONS_PROCESSED | |
|
953 | 951 | end |
|
954 | 952 | |
|
955 | 953 | end # while |
General Comments 0
You need to be logged in to leave comments.
Login now