mirror of
https://github.com/TracksApp/tracks.git
synced 2026-01-06 09:18:50 +01:00
Adds links to tables in stats page. Also updates open flash chart. The pie charts are clickable now and points to the clicked context page
git-svn-id: http://www.rousette.org.uk/svn/tracks-repos/trunk@693 a4c988fc-2ded-0310-b66e-134b36920a42
This commit is contained in:
parent
c105487411
commit
55415f7788
6 changed files with 29 additions and 17 deletions
|
|
@ -252,11 +252,11 @@ class StatsController < ApplicationController
|
|||
# Went from GROUP BY c.id to c.name for compatibility with postgresql. Since
|
||||
# the name is forced to be unique, this should work.
|
||||
@all_actions_per_context = @contexts.find_by_sql(
|
||||
"SELECT c.name AS name, count(*) AS total "+
|
||||
"SELECT c.name AS name, c.id as id, count(*) AS total "+
|
||||
"FROM contexts c, todos t "+
|
||||
"WHERE t.context_id=c.id "+
|
||||
"AND t.user_id="+@user.id.to_s+" "+
|
||||
"GROUP BY c.name "+
|
||||
"GROUP BY c.name, c.id "+
|
||||
"ORDER BY total DESC"
|
||||
)
|
||||
|
||||
|
|
@ -271,6 +271,7 @@ class StatsController < ApplicationController
|
|||
if size==pie_cutoff
|
||||
@actions_per_context[size-1]['name']='(others)'
|
||||
@actions_per_context[size-1]['total']=0
|
||||
@actions_per_context[size-1]['id']=-1
|
||||
(size-1).upto @all_actions_per_context.size()-1 do |i|
|
||||
@actions_per_context[size-1]['total']+=@all_actions_per_context[i]['total'].to_i
|
||||
end
|
||||
|
|
@ -292,11 +293,11 @@ class StatsController < ApplicationController
|
|||
# Went from GROUP BY c.id to c.name for compatibility with postgresql. Since
|
||||
# the name is forced to be unique, this should work.
|
||||
@all_actions_per_context = @contexts.find_by_sql(
|
||||
"SELECT c.name AS name, count(*) AS total "+
|
||||
"SELECT c.name AS name, c.id as id, count(*) AS total "+
|
||||
"FROM contexts c, todos t "+
|
||||
"WHERE t.context_id=c.id AND t.completed_at IS NULL AND NOT c.hide "+
|
||||
"AND t.user_id="+@user.id.to_s+" "+
|
||||
"GROUP BY c.name "+
|
||||
"GROUP BY c.name, c.id "+
|
||||
"ORDER BY total DESC"
|
||||
)
|
||||
|
||||
|
|
@ -311,6 +312,7 @@ class StatsController < ApplicationController
|
|||
if size==pie_cutoff
|
||||
@actions_per_context[size-1]['name']='(others)'
|
||||
@actions_per_context[size-1]['total']=0
|
||||
@actions_per_context[size-1]['id']=-1
|
||||
(size-1).upto @all_actions_per_context.size()-1 do |i|
|
||||
@actions_per_context[size-1]['total']+=@all_actions_per_context[i]['total'].to_i
|
||||
end
|
||||
|
|
@ -536,7 +538,7 @@ class StatsController < ApplicationController
|
|||
# Went from GROUP BY c.id to c.name for compatibility with postgresql. Since
|
||||
# the name is forced to be unique, this should work.
|
||||
@actions_per_context = @contexts.find_by_sql(
|
||||
"SELECT c.name AS name, count(*) AS total "+
|
||||
"SELECT c.id AS id, c.name AS name, count(*) AS total "+
|
||||
"FROM contexts c, todos t "+
|
||||
"WHERE t.context_id=c.id "+
|
||||
"AND t.user_id="+@user.id.to_s+" "+
|
||||
|
|
@ -549,7 +551,7 @@ class StatsController < ApplicationController
|
|||
# Went from GROUP BY c.id to c.name for compatibility with postgresql. Since
|
||||
# the name is forced to be unique, this should work.
|
||||
@running_actions_per_context = @contexts.find_by_sql(
|
||||
"SELECT c.name AS name, count(*) AS total "+
|
||||
"SELECT c.id AS id, c.name AS name, count(*) AS total "+
|
||||
"FROM contexts c, todos t "+
|
||||
"WHERE t.context_id=c.id AND t.completed_at IS NULL AND NOT c.hide "+
|
||||
"AND t.user_id="+@user.id.to_s+" "+
|
||||
|
|
@ -564,7 +566,7 @@ class StatsController < ApplicationController
|
|||
# Went from GROUP BY p.id to p.name for compatibility with postgresql. Since
|
||||
# the name is forced to be unique, this should work.
|
||||
@projects_and_actions = @projects.find_by_sql(
|
||||
"SELECT p.name, count(*) AS count "+
|
||||
"SELECT p.id, p.name, count(*) AS count "+
|
||||
"FROM projects p, todos t "+
|
||||
"WHERE p.id = t.project_id "+
|
||||
"AND p.user_id="+@user.id.to_s+" "+
|
||||
|
|
@ -579,7 +581,7 @@ class StatsController < ApplicationController
|
|||
# using GROUP BY p.name (was: p.id) for compatibility with Postgresql. Since
|
||||
# you cannot create two contexts with the same name, this will work.
|
||||
@projects_and_actions_last30days = @projects.find_by_sql([
|
||||
"SELECT p.name, count(*) AS count "+
|
||||
"SELECT p.id, p.name, count(*) AS count "+
|
||||
"FROM todos t, projects p "+
|
||||
"WHERE t.project_id = p.id AND "+
|
||||
" (t.created_at > ? OR t.completed_at > ?) "+
|
||||
|
|
@ -592,7 +594,7 @@ class StatsController < ApplicationController
|
|||
# get the first 10 projects and their running time (creation date versus
|
||||
# now())
|
||||
@projects_and_runtime_sql = @projects.find_by_sql(
|
||||
"SELECT name, created_at "+
|
||||
"SELECT id, name, created_at "+
|
||||
"FROM projects "+
|
||||
"WHERE state='active' "+
|
||||
"AND user_id="+@user.id.to_s+" "+
|
||||
|
|
@ -601,11 +603,11 @@ class StatsController < ApplicationController
|
|||
)
|
||||
|
||||
i=0
|
||||
@projects_and_runtime = Array.new(10, ["n/a", "n/a"])
|
||||
@projects_and_runtime = Array.new(10, [-1, "n/a", "n/a"])
|
||||
@projects_and_runtime_sql.each do |r|
|
||||
days = (@today - r.created_at) / @seconds_per_day
|
||||
# add one so that a project that you just create returns 1 day
|
||||
@projects_and_runtime[i]=[r.name, days.to_i+1]
|
||||
@projects_and_runtime[i]=[r.id, r.name, days.to_i+1]
|
||||
i += 1
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
<%
|
||||
1.upto 5 do |i|
|
||||
%><%=i-%> -
|
||||
<%= i <= @actions_per_context.size ? @actions_per_context[i-1]['name'] : "n/a"%>
|
||||
<%= i <= @actions_per_context.size ? link_to(@actions_per_context[i-1]['name'], {:controller => "contexts", :action => "show", :id => @actions_per_context[i-1]['id']}) : "n/a"%>
|
||||
(
|
||||
<%= i <= @actions_per_context.size ? @actions_per_context[i-1]['total'] : "n/a"%>
|
||||
)
|
||||
|
|
@ -21,7 +21,7 @@
|
|||
<%
|
||||
1.upto 5 do |i|
|
||||
%><%=i-%> -
|
||||
<%= i <= @running_actions_per_context.size ? @running_actions_per_context[i-1]['name'] : "n/a"-%>
|
||||
<%= i <= @running_actions_per_context.size ? link_to(@running_actions_per_context[i-1]['name'], {:controller => "contexts", :action => "show", :id => @running_actions_per_context[i-1]['id']}) : "n/a"-%>
|
||||
(
|
||||
<%= i <= @running_actions_per_context.size ? @running_actions_per_context[i-1]['total'] : "n/a"-%>
|
||||
)
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
<% i=0
|
||||
@projects_and_actions.each do |p|
|
||||
i+=1 -%>
|
||||
<%= i -%> - <%= p.name %> (<%=p.count %> actions) <br/>
|
||||
<%= i -%> - <%= link_to p.name, {:controller => "projects", :action => "show", :id => p.id}%> (<%=p.count %> actions) <br/>
|
||||
<% end
|
||||
if i < 10
|
||||
i.upto 10 do |j| -%>
|
||||
|
|
@ -18,7 +18,7 @@
|
|||
<% i=0
|
||||
@projects_and_actions_last30days.each do |p|
|
||||
i+=1 -%>
|
||||
<%= i -%> - <%= p.name %> (<%=p.count %> actions) <br/>
|
||||
<%= i -%> - <%= link_to p.name, {:controller => "projects", :action => "show", :id => p.id} %> (<%=p.count %> actions) <br/>
|
||||
<% end
|
||||
if i < 10
|
||||
i.upto 10 do |j| -%>
|
||||
|
|
@ -31,8 +31,8 @@
|
|||
<div class="stats_module">
|
||||
<h3>Top 10 longest running projects</h3>
|
||||
<% i=0
|
||||
@projects_and_runtime.each do |name, days|
|
||||
@projects_and_runtime.each do |id, name, days|
|
||||
i+=1 -%>
|
||||
<%= i -%> - <%= name %> (<%=days %> days) <br/>
|
||||
<%= i -%> - <%= link_to name, {:controller => "projects", :action => "show", :id => id} %> (<%=days %> days) <br/>
|
||||
<% end -%>
|
||||
</div>
|
||||
|
|
@ -11,6 +11,11 @@ end
|
|||
%><%=truncate(@actions_per_context[i]['name'],@truncate_chars, '...')%>,<%
|
||||
end
|
||||
-%><%=truncate(@actions_per_context[@actions_per_context.size()-1]['name'],@truncate_chars,'...') %>&
|
||||
&links=<%
|
||||
0.upto @actions_per_context.size()-2 do | i |
|
||||
%><%=url_for :controller => "contexts", :action => "show", :id=>@actions_per_context[i]['id']%>,<%
|
||||
end
|
||||
-%><%=url_for :controller => "contexts", :action => "show", :id=>@actions_per_context[@actions_per_context.size()-1]['id']%>&
|
||||
&colours=#d01f3c,#356aa0,#C79810,#c61fd0,#1fc6d0,#1fd076,#72d01f,#c6d01f,#d0941f,#40941f&
|
||||
&tool_tip=#x_label#: #val#%25&
|
||||
&x_label_style=9,,2,1&
|
||||
|
|
@ -11,6 +11,11 @@ end
|
|||
%><%=truncate(@actions_per_context[i]['name'], @truncate_chars, '...') %>,<%
|
||||
end
|
||||
-%><%=truncate(@actions_per_context[@actions_per_context.size()-1]['name'], @truncate_chars, '...') %>&
|
||||
&links=<%
|
||||
0.upto @actions_per_context.size()-2 do | i |
|
||||
%><%=url_for :controller => "contexts", :action => "show", :id=>@actions_per_context[i]['id']%>,<%
|
||||
end
|
||||
-%><%=url_for :controller => "contexts", :action => "show", :id=>@actions_per_context[@actions_per_context.size()-1]['id']%>&
|
||||
&colours=#d01f3c,#356aa0,#C79810,#c61fd0,#1fc6d0,#1fd076,#72d01f,#c6d01f,#d0941f,#40941f&
|
||||
&tool_tip=#x_label#: #val#%25&
|
||||
&x_label_style=9,,2,1&
|
||||
Binary file not shown.
Loading…
Add table
Add a link
Reference in a new issue