Adding payment stats
This commit is contained in:
parent
4631489eba
commit
d1985dae12
|
@ -13,8 +13,10 @@ def index
|
|||
@num_door_opens = DoorLog.where("key = 'G'").count
|
||||
@today_door_opens = DoorLog.where("key = 'G' AND created_at > ?", DateTime.now - 1.day).count
|
||||
@recent_door_opens = DoorLog.where("key = 'G' AND created_at > ?", DateTime.now - 7.days).count
|
||||
@num_door_denieds = DoorLog.where("key = 'f'").count
|
||||
@recent_door_denieds = DoorLog.where("key = 'f' AND created_at > ?", DateTime.now - 7.days).count
|
||||
@num_door_denieds = DoorLog.where("key = 'D'").count
|
||||
@recent_door_denieds = DoorLog.where("key = 'D' AND created_at > ?", DateTime.now - 7.days).count
|
||||
@num_logins = User.sum('sign_in_count')
|
||||
@recent_logins = User.where('current_sign_in_at > ?',Date.today - 7.days).count
|
||||
@num_macs = Mac.count
|
||||
@recent_macs = Mac.where("since > ?", DateTime.now - 1.day).count
|
||||
|
||||
|
|
|
@ -16,6 +16,28 @@ class PaymentsController < ApplicationController
|
|||
# GET /payments.json
|
||||
def index
|
||||
@payments = @payments.order("date DESC")
|
||||
payment_months = @payments.group_by{ |p| p.date.beginning_of_month }
|
||||
@payments_by_month = []
|
||||
payment_months.each do |month|
|
||||
# Only grab the last year from today
|
||||
if month.first > (Date.today - 1.year) && month.first < Date.today
|
||||
# Calculate sum of amounts for each month and store at end of month array
|
||||
@payments_by_month << {:month => month.first, :sum => month.last.sum{|p|
|
||||
if p.amount
|
||||
p.amount.to_i
|
||||
else
|
||||
if p.user
|
||||
Rails.logger.info p.user.member_level
|
||||
p.user.member_level.to_i
|
||||
else
|
||||
Rails.logger.info p.inspect
|
||||
Rails.logger.info p.user.inspect
|
||||
0
|
||||
end
|
||||
end
|
||||
}}
|
||||
end
|
||||
end
|
||||
|
||||
respond_to do |format|
|
||||
format.html # index.html.erb
|
||||
|
|
|
@ -35,6 +35,8 @@
|
|||
<dd><%= @num_door_opens %> (<%= @today_door_opens %> today, <%= @recent_door_opens %> in the last 7 days)</dd>
|
||||
<dt># of Door Accesses Denied:</dt>
|
||||
<dd><%= @num_door_denieds %> (<%= @recent_door_denieds %> in the last 7 days)</dd>
|
||||
<dt># of Logins:</dt>
|
||||
<dd><%= @num_logins %> (<%= @recent_logins %> users today)</dd>
|
||||
<dt># of Computers in this DB:</dt>
|
||||
<dd><%= @num_macs %> (<%= @recent_macs %> seen today)</dd>
|
||||
</dl>
|
||||
|
|
|
@ -7,6 +7,15 @@
|
|||
<%= link_to 'IPN', ipns_path %>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<h3>Payments by Month</h3>
|
||||
<dl>
|
||||
<% @payments_by_month.each do |month| %>
|
||||
<dt><%= month[:month] %></dt>
|
||||
<dd><%= month[:sum] %></dd>
|
||||
<% end %>
|
||||
</dl>
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<th>Payee</th>
|
||||
|
|
Loading…
Reference in New Issue
Block a user