-
-
Save janxious/257156 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<%# Total number of tickets for this customer by time frame -%> | |
<table> | |
<thead> | |
<tr> | |
<th>Timeframe</th> | |
<th>Opened</th> | |
<th>Closed</th> | |
</tr> | |
</thead> | |
<tbody> | |
<% Timeframe.all.map{|t| {:name => t.name, | |
:total => @tickets.select{|t| t.timeframe_id == timeframe.id }.size, | |
:closed => @tickets.select {|t| t.timeframe_id == timeframe.id }.select { |t| t.closed? }.size}}.each do |timeframe| -%> | |
<tr> | |
<td><strong><%= timeframe[:name] %><strong></td> | |
<td><%= timeframe[:total] %> | |
<td><%= timeframe[:closed] %> | |
</tr> | |
<% end -%> | |
<tr> | |
<td><strong>Totals</strong></td> | |
<td><%= @tickets.size %></td> | |
<td><%= @tickets.select(&:closed?).size %></td> | |
</tr> | |
</tbody> | |
</table> | |
<br /> | |
<br /> | |
<%# Total number of tickets for this customer by type -%> | |
<table> | |
<thead> | |
<tr> | |
<th>Type</th> | |
<th> </th> | |
</tr> | |
</thead> | |
<tbody> | |
<% @ticket_type_and_tickets_size do |t| -%> | |
<tr> | |
<td><strong><%= t[:name] %></strong></td> | |
<td><%= t[:size] %> | |
</tr> | |
<% end -%> | |
</tbody> | |
</table> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ReportsController < Blah | |
#... | |
def report_results | |
#... | |
@tickets = whatever | |
@ticket_type_and_tickets_size = TicketType.all.map{|tt| { :name => t.name, :size => @tickets.select{ |t| tt.id == t.ticket_type_id}.size } } | |
#... | |
end | |
#... | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment