From f1b752a4c43eb6ad79918767c83c22c33eb329fc Mon Sep 17 00:00:00 2001 From: Will Bradley Date: Sat, 9 Feb 2013 02:40:38 -0700 Subject: [PATCH] Updating homepage to display cooler door/mac stats --- app/controllers/home_controller.rb | 10 ++++++++-- app/views/home/index.html.erb | 16 +++++++++++++--- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/app/controllers/home_controller.rb b/app/controllers/home_controller.rb index 34f86eb..7d19623 100644 --- a/app/controllers/home_controller.rb +++ b/app/controllers/home_controller.rb @@ -5,10 +5,16 @@ def index @recent_certs = UserCertification.where("created_at > ?", DateTime.now - 7.days).count @num_users = User.count @recent_users = User.where("created_at > ?", DateTime.now - 7.days).count + if can? :read, User then + @recent_user_names = User.where("created_at > ?", DateTime.now - 7.days) + end @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 = 'D'").count - @recent_door_denieds = DoorLog.where("key = 'D' 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_macs = Mac.count + @recent_macs = Mac.where("since > ?", DateTime.now - 1.day).count respond_to do |format| format.html # index.html.erb diff --git a/app/views/home/index.html.erb b/app/views/home/index.html.erb index fe80b21..b45e344 100644 --- a/app/views/home/index.html.erb +++ b/app/views/home/index.html.erb @@ -7,14 +7,24 @@ <% if user_signed_in? && current_user.member.to_i < current_user.member_level.to_i then %>

Looks like we haven't acknowledged a recent payment for you yet. This could be because we're slow, or this app just got started, but if in doubt please see your profile for payment instructions, or consider updating your membership level to something accurate.
Thanks for supporting HeatSync!

<% end %> +<% if ((can? :read, User) && (@recent_user_names.count > 1)) then %> +

New People:

+ +<% end %>

Cool Stats:

# of People in this DB:
-
<%= @num_users %> (<%= @recent_users %> in the last 7 days)
+
<%= @num_users %> (<%= @recent_users %> new in the last 7 days)
# of People Certified:
-
<%= @num_certs %> (<%= @recent_certs %> in the last 7 days)
+
<%= @num_certs %> (<%= @recent_certs %> new in the last 7 days)
# of Door Accesses Granted:
-
<%= @num_door_opens %> (<%= @recent_door_opens %> in the last 7 days)
+
<%= @num_door_opens %> (<%= @today_door_opens %> today, <%= @recent_door_opens %> in the last 7 days)
# of Door Accesses Denied:
<%= @num_door_denieds %> (<%= @recent_door_denieds %> in the last 7 days)
+
# of Computers in this DB:
+
<%= @num_macs %> (<%= @recent_macs %> seen today)