Skip to content

Commit

Permalink
Render monthly transaction statistics for admins
Browse files Browse the repository at this point in the history
Render the Statistics::MonthlyStatistics in a more visible place, rather
than requiring a developer to run the stats:show rake task.
  • Loading branch information
garethrees committed Feb 9, 2024
1 parent 721bd79 commit ffbfb5a
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 0 deletions.
2 changes: 2 additions & 0 deletions app/controllers/admin/statistics_controller.rb
Expand Up @@ -15,5 +15,7 @@ def index
@comment_count = Comment.count
@request_by_state = InfoRequest.group('described_state').count
@tracks_by_type = TrackThing.group('track_type').count

@monthly_transactions = Statistics::MonthlyTransactions.new
end
end
24 changes: 24 additions & 0 deletions app/views/admin/statistics/index.html.erb
Expand Up @@ -80,3 +80,27 @@
</div>
</div>
</div>

<div class="row">
<div class="span12">
<h2>Transactions</h2>

<table class="table table-condensed table-hover">
<% @monthly_transactions.each_with_index do |row, index| %>
<tr>
<% if index.zero? %>
<% row.each do |cell| %>
<th style="text-orientation: sideways; writing-mode: vertical-lr;">
<%= cell %>
</th>
<% end %>
<% else %>
<% row.each do |cell| %>
<%= tag.td cell, class: { muted: cell.to_i.zero? } %>
<% end %>
<% end %>
</tr>
<% end %>
</table>
</div>
</div>
6 changes: 6 additions & 0 deletions spec/controllers/admin/statistics_controller_spec.rb
Expand Up @@ -59,5 +59,11 @@
"all_successful_requests" => 6,
"all_new_requests" => 7 })
end

it 'assigns the monthly transactions' do
get :index
expect(assigns[:monthly_transactions]).
to be_a(Statistics::MonthlyTransactions)
end
end
end

0 comments on commit ffbfb5a

Please sign in to comment.