mirror of
https://github.com/TracksApp/tracks.git
synced 2026-03-14 16:26:32 +01:00
further refactorings and tests
one test is failing, will fix that next time
This commit is contained in:
parent
80d8d2b67a
commit
2349bee535
8 changed files with 289 additions and 182 deletions
|
|
@ -5,33 +5,32 @@
|
|||
&y_ticks=5,10,5&
|
||||
&filled_bar=50,0x9933CC,0x8010A0&
|
||||
&values=
|
||||
<% @count = @max_days > @cut_off*7 ? @cut_off : @max_days/7
|
||||
@count = @count.to_i
|
||||
0.upto @count-1 do |i| -%>
|
||||
<% @count = @max_weeks > @cut_off ? @cut_off : @max_weeks
|
||||
0.upto @count.to_i-1 do |i| -%>
|
||||
<%= @actions_completion_time_hash[i] -%>,
|
||||
<% end -%>
|
||||
<%
|
||||
<%
|
||||
@sum=0
|
||||
@count.upto @max_days/7 do |i|
|
||||
@count.upto @max_weeks do |i|
|
||||
@sum += @actions_completion_time_hash[i]
|
||||
end -%>
|
||||
<%=@sum%>&
|
||||
&line_2=2,0xFF0000&
|
||||
&values_2=
|
||||
<% total=0
|
||||
@count = @max_days > @cut_off*7 ? @cut_off : @max_days/7
|
||||
@count = @max_weeks > @cut_off ? @cut_off : @max_weeks
|
||||
0.upto @count-1 do |i|
|
||||
total += @actions_completion_time_hash[i]*100.0/@sum_actions -%>
|
||||
total += @actions_completion_time_hash[i]*100.0/@actions_completion_time.count -%>
|
||||
<%= total -%>,
|
||||
<% end -%>
|
||||
<%= total+@sum*100.0/@sum_actions%>&
|
||||
<%= total+@sum*100.0/@actions_completion_time.count%>&
|
||||
&x_labels=within 1,
|
||||
<% 1.upto @count-1 do |i| -%>
|
||||
<%= i %>-<%= i+1 %>,
|
||||
<% end -%>
|
||||
> <%= @count %>&
|
||||
&y_min=0&
|
||||
<% # add one to @max for people who have no actions completed yet.
|
||||
<% # add one to @max for people who have no actions completed yet.
|
||||
# OpenFlashChart cannot handle y_max=0 -%>
|
||||
&y_max=<%=1+@max_actions+@max_actions/10-%>&
|
||||
&show_y2=true&
|
||||
|
|
|
|||
|
|
@ -1,3 +1,9 @@
|
|||
<%-
|
||||
url_array = Array.new(13){ |i| url_for :controller => 'stats', :action => 'actions_done_last_years'}
|
||||
created_count_array = Array.new(13){ |i| @actions_created_last12months.count/12.0 }
|
||||
done_count_array = Array.new(13){ |i| @actions_done_last12months.count/12.0 }
|
||||
month_names = Array.new(13){ |i| Date::MONTHNAMES[ (Time.now.mon - i -1 ) % 12 + 1 ]}
|
||||
-%>
|
||||
&title=<%= t('stats.actions_lastyear_title') %>,{font-size:16},&
|
||||
&y_legend=<%= t('stats.legend.number_of_actions') %>,12,0x736AFF&
|
||||
&x_legend=<%= t('stats.legend.months_ago') %>,12,0x736AFF&
|
||||
|
|
@ -10,22 +16,19 @@
|
|||
&line_6=2,0xAA0000, <%= t('stats.labels.month_avg_completed', :months => 3) %>, 9&
|
||||
&line_7=1,0xAA0000&
|
||||
&line_8=1,0x007700&
|
||||
&values=<% 0.upto 11 do |i| -%><%= @actions_created_last12months_hash[i]%>,<% end -%><%= @actions_created_last12months_hash[12]%>&
|
||||
&links=<% 0.upto 11 do |i| -%><%= url_for :controller => 'stats', :action => 'actions_done_last_years' %>,<% end -%><%= url_for :controller => 'stats', :action => 'actions_done_last_years' %>&
|
||||
&links_2=<% 0.upto 11 do |i| -%><%= url_for :controller => 'stats', :action => 'actions_done_last_years' %>,<% end -%><%= url_for :controller => 'stats', :action => 'actions_done_last_years' %>&
|
||||
&values_2=<% 0.upto 11 do |i| -%><%= @actions_done_last12months_hash[i]%>,<% end -%><%= @actions_done_last12months_hash[12]%>&
|
||||
&values_3=<%0.upto 11 do |i| -%><%=@sum_actions_created_last12months/12.0-%>,<%end-%><%=@sum_actions_created_last12months/12.0-%>&
|
||||
&values_4=<%0.upto 11 do |i| -%><%=@sum_actions_done_last12months/12.0-%>,<%end-%><%=@sum_actions_done_last12months/12.0-%>&
|
||||
&values_5=<%0.upto 11 do |i| -%><%=@actions_created_avg_last12months_hash[i]-%>,<%end-%><%=@actions_created_avg_last12months_hash[12]-%>&
|
||||
&values_6=<%0.upto 11 do |i| -%><%=@actions_done_avg_last12months_hash[i]-%>,<%end-%><%=@actions_done_avg_last12months_hash[12]-%>&
|
||||
&values_7=<%=@interpolated_actions_created_this_month%>,<%=@actions_done_avg_last12months_hash[1]%>&
|
||||
&values_8=<%=@interpolated_actions_done_this_month%>,<%=@actions_created_avg_last12months_hash[1]%>&
|
||||
&x_labels=<%0.upto 11 do |i| -%>
|
||||
<%= Date::MONTHNAMES[ (Time.now.mon - i -1 ) % 12 + 1 ] -%>,
|
||||
<% end -%>
|
||||
<%= Date::MONTHNAMES[(Time.now.mon - 12 -1 ) % 12 + 1] -%>&
|
||||
&values=<%= @actions_created_last12months_array.join(",")%>&
|
||||
&links=<%= url_array.join(",")%>&
|
||||
&links_2=<%= url_array.join(",")%>&
|
||||
&values_2=<%= @actions_done_last12months_array.join(",")%>&
|
||||
&values_3=<%= created_count_array.join(",")%>&
|
||||
&values_4=<%= done_count_array.join(",")%>&
|
||||
&values_5=<%= @actions_created_avg_last12months_array.join(",")%>&
|
||||
&values_6=<%= @actions_done_avg_last12months_array.join(",")%>&
|
||||
&values_7=<%= @interpolated_actions_created_this_month%>,<%=@actions_done_avg_last12months_array[1]%>&
|
||||
&values_8=<%= @interpolated_actions_done_this_month%>,<%=@actions_created_avg_last12months_array[1]%>&
|
||||
&x_labels=<%= month_names.join(",")%>&
|
||||
&y_min=0&
|
||||
<% # add one to @max for people who have no actions completed yet.
|
||||
<% # add one to @max for people who have no actions completed yet.
|
||||
# OpenFlashChart cannot handle y_max=0 -%>
|
||||
&y_max=<%=@max+@max/10+1-%>&
|
||||
&x_label_style=9,,2,&
|
||||
|
|
@ -16,18 +16,18 @@
|
|||
<% end -%><%= @actions_done_last30days_hash[30]%>&
|
||||
&values_3=
|
||||
<%0.upto 29 do |i| -%>
|
||||
<%=@sum_actions_created_last30days/30.0-%>,
|
||||
<%=@actions_created_last30days.count/30.0-%>,
|
||||
<%end-%>
|
||||
<%=@sum_actions_created_last30days/30.0-%>&
|
||||
<%=@actions_created_last30days.count/30.0-%>&
|
||||
&values_4=
|
||||
<%0.upto 29 do |i| -%>
|
||||
<%=@sum_actions_done_last30days/30.0-%>,
|
||||
<%=@actions_done_last30days.count/30.0-%>,
|
||||
<%end-%>
|
||||
<%=@sum_actions_done_last30days/30.0-%>&
|
||||
<%=@actions_done_last30days.count/30.0-%>&
|
||||
&x_labels=
|
||||
<%0.upto 29 do |i|
|
||||
<%0.upto 29 do |i|
|
||||
seconds = i * 24 * 60 * 60
|
||||
delta = Time.now-seconds
|
||||
delta = Time.now-seconds
|
||||
-%>
|
||||
<%= delta.strftime("%a %d-%m") -%>,
|
||||
<% end
|
||||
|
|
@ -36,7 +36,7 @@
|
|||
<%= delta.strftime("%a %d-%m") -%>&
|
||||
&y_min=0&
|
||||
<% # max + 10% for some extra space at the top
|
||||
# add one to @max for people who have no actions completed yet.
|
||||
# add one to @max for people who have no actions completed yet.
|
||||
# OpenFlashChart cannot handle y_max=0 -%>
|
||||
&y_max=<%=@max+@max/10+1 -%>&
|
||||
&x_label_style=9,,2,3&
|
||||
|
|
@ -1,3 +1,8 @@
|
|||
<%-
|
||||
created_count_array = Array.new(@month_count){ |i| @actions_created_last_months.count/@month_count }
|
||||
done_count_array = Array.new(@month_count){ |i| @actions_done_last_months.count/@month_count }
|
||||
month_names = Array.new(@month_count){ |i| Date::MONTHNAMES[ (Time.now.mon - i -1 ) % 12 + 1 ]+ " " + (Time.now - i.months).year.to_s}
|
||||
-%>
|
||||
&title=<%= t('stats.actions_last_year') %>,{font-size:16},&
|
||||
&y_legend=<%= t('stats.actions_last_year_legend.number_of_actions') %>,12,0x736AFF&
|
||||
&x_legend=<%= t('stats.actions_last_year_legend.months_ago') %>,12,0x736AFF&
|
||||
|
|
@ -10,20 +15,17 @@
|
|||
&line_6=2,0xAA0000, <%= t('stats.labels.month_avg_completed', :months => 3) %>, 9&
|
||||
&line_7=1,0xAA0000&
|
||||
&line_8=1,0x007700&
|
||||
&values=<% 0.upto @month_count-1 do |i| -%><%= @actions_created_last_months_hash[i]%>,<% end -%><%= @actions_created_last_months_hash[@month_count]%>&
|
||||
&values_2=<% 0.upto @month_count-1 do |i| -%><%= @actions_done_last_months_hash[i]%>,<% end -%><%= @actions_done_last_months_hash[@month_count]%>&
|
||||
&values_3=<%0.upto @month_count-1 do |i| -%><%=@sum_actions_created_last_months/@month_count-%>,<%end-%><%=@sum_actions_created_last_months/@month_count-%>&
|
||||
&values_4=<%0.upto @month_count-1 do |i| -%><%=@sum_actions_done_last_months/@month_count-%>,<%end-%><%=@sum_actions_done_last_months/@month_count-%>&
|
||||
&values_5=<%0.upto @month_count-1 do |i| -%><%=@actions_created_avg_last_months_hash[i]-%>,<%end-%><%=@actions_created_avg_last_months_hash[@month_count]-%>&
|
||||
&values_6=<%0.upto @month_count-1 do |i| -%><%=@actions_done_avg_last_months_hash[i]-%>,<%end-%><%=@actions_done_avg_last_months_hash[@month_count]-%>&
|
||||
&values_7=<%=@interpolated_actions_created_this_month%>,<%=@actions_done_avg_last_months_hash[1]%>&
|
||||
&values_8=<%=@interpolated_actions_done_this_month%>,<%=@actions_created_avg_last_months_hash[1]%>&
|
||||
&x_labels=<%0.upto @month_count-1 do |i| -%>
|
||||
<%= Date::MONTHNAMES[ (Time.now.mon - i -1 ) % 12 + 1 ] + " " + (Time.now - i.months).year.to_s -%>,
|
||||
<% end -%>
|
||||
<%= Date::MONTHNAMES[(Time.now.mon - @month_count -1 ) % 12 + 1] + " " + (Time.now - @month_count.months).year.to_s -%>&
|
||||
&values=<%= @actions_created_last_months_array.join(",")%>&
|
||||
&values_2=<%= @actions_done_last_months_array.join(",")%>&
|
||||
&values_3=<%= created_count_array.join(",")%>&
|
||||
&values_4=<%= done_count_array.join(",")%>&
|
||||
&values_5=<%= @actions_created_avg_last_months_array.join(",")%>&
|
||||
&values_6=<%= @actions_done_avg_last_months_array.join(",")%>&
|
||||
&values_7=<%= @interpolated_actions_created_this_month%>,<%=@actions_done_avg_last_months_array[1]%>&
|
||||
&values_8=<%= @interpolated_actions_done_this_month%>,<%=@actions_created_avg_last_months_array[1]%>&
|
||||
&x_labels=<%= month_names.join(",")%>&
|
||||
&y_min=0&
|
||||
<% # add one to @max for people who have no actions completed yet.
|
||||
<% # add one to @max for people who have no actions completed yet.
|
||||
# OpenFlashChart cannot handle y_max=0 -%>
|
||||
&y_max=<%=@max+@max/10+1-%>&
|
||||
&x_label_style=9,,2,&
|
||||
|
|
@ -5,13 +5,13 @@
|
|||
&y_ticks=5,10,5&
|
||||
&filled_bar=50,0x9933CC,0x8010A0&
|
||||
&values=
|
||||
<% @count = @max_days > @cut_off*7 ? @cut_off : (@max_days/7).to_i
|
||||
0.upto @count-1 do |i| -%>
|
||||
<% @count = @max_weeks > @cut_off ? @cut_off : @max_weeks
|
||||
0.upto @count.to_i-1 do |i| -%>
|
||||
<%= @actions_running_time_hash[i] -%>,
|
||||
<% end -%>
|
||||
<%
|
||||
<%
|
||||
@sum=0
|
||||
@count.upto((@max_days/7).to_i) {|i| @sum += @actions_running_time_hash[i]} -%>
|
||||
@count.upto(@max_weeks.to_i) {|i| @sum += @actions_running_time_hash[i]} -%>
|
||||
<%=@sum%>&
|
||||
&links=<%
|
||||
0.upto(@count-1) { |i| %><%= url_for :controller => 'stats', :action => 'show_selected_actions_from_chart', :index => i, :id=> "art" %>, <% }
|
||||
|
|
@ -19,20 +19,20 @@
|
|||
&line_2=2,0xFF0000&
|
||||
&values_2=
|
||||
<% total=0
|
||||
@count = @max_days > @cut_off*7 ? @cut_off : (@max_days/7).to_i
|
||||
0.upto @count-1 do |i|
|
||||
@count = @max_weeks > @cut_off ? @cut_off : @max_weeks
|
||||
0.upto @count.to_i-1 do |i|
|
||||
total += @actions_running_time_hash[i] -%>
|
||||
<%= total*100.0/@sum_actions -%>,
|
||||
<%= total*100.0/@actions_running_time.count -%>,
|
||||
<% end -%>
|
||||
<%= (total+@sum)*100.0/@sum_actions%>&
|
||||
<%= (total+@sum)*100.0/@actions_running_time.count%>&
|
||||
&x_labels=< 1,
|
||||
<% 1.upto @count-1 do |i| -%>
|
||||
<%= i %>-<%= i+1 %>,
|
||||
<% end -%>
|
||||
><%=@count-%>&
|
||||
&y_min=0&
|
||||
<% @max_actions = @sum > @max_actions ? @sum : @max_actions -%>
|
||||
<% # add one to @max for people who have no actions completed yet.
|
||||
<% @max_actions = [@sum,@max_actions].max -%>
|
||||
<% # add one to @max for people who have no actions completed yet.
|
||||
# OpenFlashChart cannot handle y_max=0 -%>
|
||||
&y_max=<%=1+@max_actions+@max_actions/10-%>&
|
||||
&x_label_style=9,,2,2&
|
||||
|
|
|
|||
|
|
@ -5,11 +5,11 @@
|
|||
&y_ticks=5,10,5&
|
||||
&filled_bar=50,0x9933CC,0x8010A0&
|
||||
&values=
|
||||
<% @count = @max_days > @cut_off*7 ? @cut_off : (@max_days/7).to_i
|
||||
<% @count = @max_weeks > @cut_off ? @cut_off : @max_weeks
|
||||
0.upto(@count-1) { |i| -%><%= @actions_running_time_hash[i] -%>,<% } %>
|
||||
<%
|
||||
<%
|
||||
@sum=0
|
||||
@count.upto((@max_days/7).to_i) { |i| @sum += @actions_running_time_hash[i] } -%>
|
||||
@count.upto(@max_weeks.to_i) { |i| @sum += @actions_running_time_hash[i] } -%>
|
||||
<%=@sum%>&
|
||||
&links=<%
|
||||
0.upto(@count-1) { |i| %><%= url_for :controller => 'stats', :action => 'show_selected_actions_from_chart', :index => i, :id=> "avrt" %>, <% }
|
||||
|
|
@ -17,12 +17,12 @@
|
|||
&line_2=2,0xFF0000&
|
||||
&values_2=
|
||||
<% total=0
|
||||
@count = @max_days > @cut_off*7 ? @cut_off : (@max_days/7).to_i
|
||||
0.upto @count-1 do |i|
|
||||
@count = @max_weeks > @cut_off ? @cut_off : @max_weeks
|
||||
0.upto @count-1 do |i|
|
||||
total += @actions_running_time_hash[i] -%>
|
||||
<%= total*100.0/@sum_actions -%>,
|
||||
<%= total*100.0/@actions_running_time.count -%>,
|
||||
<% end -%>
|
||||
<%= (total+@sum)*100.0/@sum_actions%>&
|
||||
<%= (total+@sum)*100.0/@actions_running_time.count%>&
|
||||
&x_labels=< 1,
|
||||
<% 1.upto @count-1 do |i| -%>
|
||||
<%= i %>-<%= i+1 %>,
|
||||
|
|
@ -30,7 +30,7 @@
|
|||
><%=@count-%>&
|
||||
&y_min=0&
|
||||
<% @max_actions = @sum > @max_actions ? @sum : @max_actions -%>
|
||||
<% # add one to @max for people who have no actions completed yet.
|
||||
<% # add one to @max for people who have no actions completed yet.
|
||||
# OpenFlashChart cannot handle y_max=0 -%>
|
||||
&y_max=<%=1+@max_actions+@max_actions/10-%>&
|
||||
&x_label_style=9,,2,2&
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue