diff --git a/app/controllers/graphs_controller.rb b/app/controllers/graphs_controller.rb index 0f87eac..a7a5f74 100755 --- a/app/controllers/graphs_controller.rb +++ b/app/controllers/graphs_controller.rb @@ -10,6 +10,23 @@ class GraphsController < ApplicationController helper IssuesHelper + def issue_status_flow + # Get the top visible projects by issue count + sql = " select is1.id as old_status, is2.id as new_status, count(*) as changes_count" + sql << " from journals as j" + sql << " left join journal_details as jd on j.id = jd.journal_id" + sql << " left join issue_statuses as is1 on jd.old_value = is1.id" + sql << " left join issue_statuses as is2 on jd.value = is2.id" + sql << " where journalized_type = 'issue' and prop_key = 'status_id' and DATE_SUB(CURRENT_TIMESTAMP, INTERVAL 10 DAY) <= created_on" + sql << " group by old_value, value" + sql << " order by is1.position, is2.position" + @status_changes = ActiveRecord::Base.connection.select_all(sql) + @issue_statuses = IssueStatus.find(:all).sort { |a,b| a.position<=>b.position } + + headers["Content-Type"] = "image/svg+xml" + render :layout => false + end + def issue_growth end diff --git a/app/views/graphs/issue_status_flow.html.erb b/app/views/graphs/issue_status_flow.html.erb new file mode 100644 index 0000000..dc8ae04 --- /dev/null +++ b/app/views/graphs/issue_status_flow.html.erb @@ -0,0 +1,37 @@ + + + +<% + issue_statuses_by_id = @issue_statuses.index_by { |issue_status| issue_status.id } + + points = Hash.new + i = -1 + @issue_statuses.each do |issue_status| + points[issue_status.id] = {"x" => Math.sin(2*Math::PI*i/@issue_statuses.size)*100 + 150, "y" => Math.cos(2*Math::PI*i/@issue_statuses.size)*100 + 150} + i -= 1 + end +%> + + + + <% @status_changes.each do |status_change| %> + " + x2="<%= points[status_change["old_status"].to_i]["x"] %>" + y1="<%= points[status_change["new_status"].to_i]["y"] %>" + x1="<%= points[status_change["new_status"].to_i]["x"] %>" + stroke-width="<%= status_change["changes_count"].to_i %>" + /> + <% end %> + + + <% points.each do |status_id, point| %> + " cy="<%= point["y"] %>" r="40" /> + <% end %> + + + <% points.each do |status_id, point| %> + " y="<%= point["y"] %>"><%= issue_statuses_by_id[status_id] %> + <% end %> + + \ No newline at end of file diff --git a/assets/stylesheets/issue_status_flow.css b/assets/stylesheets/issue_status_flow.css new file mode 100755 index 0000000..093b8a5 --- /dev/null +++ b/assets/stylesheets/issue_status_flow.css @@ -0,0 +1,7 @@ +.line1 { stroke: #666666 !important; } .fill1 { fill: #666666 !important; } .key1 { fill: #666666 !important; } +.line2 { stroke: #507AAA !important; } .fill2 { fill: #BACCE0 !important; } .key2 { fill: #507AAA !important; } + +.fill1, .fill2 { fill-opacity: 0.6 !important; } +.line1, .line2 { stroke-width: 2px !important; } + +.guideLines { stroke-opacity: 0.2 !important; } \ No newline at end of file