mirror of
https://github.com/TracksApp/tracks.git
synced 2026-02-16 04:08:08 +01:00
Simplify stats projects view
Use `each_with_index` instead of hand-wrought index to loop through projects, and use a partial for the duplicated empty list items.
This commit is contained in:
parent
2686a0d3b5
commit
254179b4c8
2 changed files with 15 additions and 33 deletions
3
app/views/stats/_null_list_item.html.erb
Normal file
3
app/views/stats/_null_list_item.html.erb
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
<% from.upto 10 do |i| -%>
|
||||
<%= i -%> - <%=t('common.not_available_abbr')%> (<%=t('common.not_available_abbr')%>) <br/>
|
||||
<% end -%>
|
||||
|
|
@ -1,44 +1,23 @@
|
|||
<div class="stats_module">
|
||||
<h3><%= t('stats.top10_projects') %></h3>
|
||||
<% i=0
|
||||
@projects_and_actions.each do |p|
|
||||
i+=1 -%>
|
||||
<%= i -%> - <%= link_to p.name, {:controller => "projects", :action => "show", :id => p.id}%> (<%=p.count %> <%= t('common.actions_midsentence', :count => p.count) %>) <br/>
|
||||
<% end
|
||||
if i < 10
|
||||
(i+1).upto 10 do |j| -%>
|
||||
<%= j -%> - <%=t('common.not_available_abbr')%> (<%=t('common.not_available_abbr')%>) <br/>
|
||||
<% end
|
||||
end
|
||||
-%>
|
||||
<% @projects_and_actions.each_with_index do |p, i| -%>
|
||||
<%= i + 1 -%> - <%= link_to p.name, {:controller => "projects", :action => "show", :id => p.id}%> (<%=p.count %> <%= t('common.actions_midsentence', :count => p.count) %>) <br/>
|
||||
<% end -%>
|
||||
<%= render :partial => 'null_list_item', :locals => {:from => @projects_and_actions.size + 1} -%>
|
||||
</div>
|
||||
|
||||
<div class="stats_module">
|
||||
<h3><%= t('stats.top10_projects_30days') %></h3>
|
||||
<% i=0
|
||||
@projects_and_actions_last30days.each do |p|
|
||||
i+=1 -%>
|
||||
<%= i -%> - <%= link_to p.name, {:controller => "projects", :action => "show", :id => p.id} %> (<%=p.count %> <%= t('common.actions_midsentence', :count => p.count) %>) <br/>
|
||||
<% end
|
||||
if i < 10
|
||||
(i+1).upto 10 do |j| -%>
|
||||
<%= j -%> - <%=t('common.not_available_abbr')%> (<%=t('common.not_available_abbr')%>) <br/>
|
||||
<% end
|
||||
end
|
||||
-%>
|
||||
<% @projects_and_actions_last30days.each_with_index do |p, i| -%>
|
||||
<%= i + 1 -%> - <%= link_to p.name, {:controller => "projects", :action => "show", :id => p.id} %> (<%=p.count %> <%= t('common.actions_midsentence', :count => p.count) %>) <br/>
|
||||
<% end -%>
|
||||
<%= render :partial => 'null_list_item', :locals => {:from => @projects_and_actions_last30days.size + 1} -%>
|
||||
</div>
|
||||
|
||||
<div class="stats_module">
|
||||
<h3><%= t('stats.top10_longrunning') %></h3>
|
||||
<% i=0
|
||||
@projects_and_runtime.each do |p|
|
||||
i+=1 -%>
|
||||
<%= i -%> - <%= link_to p.name, {:controller => "projects", :action => "show", :id => p.id} %> (<%=p.age_in_days %> <%= t('common.days_midsentence', :count => p.age_in_days) %>) <br/>
|
||||
<% end
|
||||
if i < 10
|
||||
(i+1).upto 10 do |j| -%>
|
||||
<%= j -%> - <%=t('common.not_available_abbr')%> (<%=t('common.not_available_abbr')%>) <br/>
|
||||
<% end
|
||||
end
|
||||
-%>
|
||||
<% @projects_and_runtime.each_with_index do |p, i| -%>
|
||||
<%= i + 1 -%> - <%= link_to p.name, {:controller => "projects", :action => "show", :id => p.id} %> (<%=p.age_in_days %> <%= t('common.days_midsentence', :count => p.age_in_days) %>) <br/>
|
||||
<% end -%>
|
||||
<%= render :partial => 'null_list_item', :locals => {:from => @projects_and_runtime.size + 1} -%>
|
||||
</div>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue