2012-09-02 09:57:34 +00:00
|
|
|
class HomeController < ApplicationController
|
|
|
|
|
|
|
|
def index
|
2013-01-26 05:30:05 +00:00
|
|
|
@num_certs = UserCertification.count
|
|
|
|
@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
|
2013-09-29 03:17:38 +00:00
|
|
|
# Payments: member levels are multipled by 10 to indicate current payment; 25 x 10 = 250
|
2013-08-28 15:19:01 +00:00
|
|
|
@num_paid_users = User.all.select{|u| u.member_status >= 250 }.count
|
2013-09-29 03:17:38 +00:00
|
|
|
@num_plus_users = User.all.select{|u| u.member_status == 1000 }.count
|
|
|
|
@num_basic_users = User.all.select{|u| u.member_status == 500 }.count
|
|
|
|
@num_associate_users = User.all.select{|u| u.member_status == 250 }.count
|
2013-08-28 15:19:01 +00:00
|
|
|
@num_delinquent_users = User.all.select{|u| !u.payment_status }.count
|
2013-02-09 09:40:38 +00:00
|
|
|
if can? :read, User then
|
2013-02-14 07:29:22 +00:00
|
|
|
@recent_user_names = User.where("member_level > 10").accessible_by(current_ability).order('created_at desc').limit(5)
|
2013-02-09 09:40:38 +00:00
|
|
|
end
|
2013-01-26 05:30:05 +00:00
|
|
|
@num_door_opens = DoorLog.where("key = 'G'").count
|
2013-02-09 09:40:38 +00:00
|
|
|
@today_door_opens = DoorLog.where("key = 'G' AND created_at > ?", DateTime.now - 1.day).count
|
2013-01-26 05:30:05 +00:00
|
|
|
@recent_door_opens = DoorLog.where("key = 'G' AND created_at > ?", DateTime.now - 7.days).count
|
2013-09-28 08:30:52 +00:00
|
|
|
@num_door_denieds = DoorLog.where("key = 'D'").count
|
2013-09-29 03:17:38 +00:00
|
|
|
@recent_door_denieds = DoorLog.where("key = 'D' AND created_at > ?", DateTime.now - 1.month).count
|
2013-09-28 08:30:52 +00:00
|
|
|
@num_logins = User.sum('sign_in_count')
|
|
|
|
@recent_logins = User.where('current_sign_in_at > ?',Date.today - 7.days).count
|
2013-02-09 09:40:38 +00:00
|
|
|
@num_macs = Mac.count
|
|
|
|
@recent_macs = Mac.where("since > ?", DateTime.now - 1.day).count
|
2013-01-26 05:30:05 +00:00
|
|
|
|
2012-09-02 09:57:34 +00:00
|
|
|
respond_to do |format|
|
|
|
|
format.html # index.html.erb
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2013-09-28 11:59:19 +00:00
|
|
|
def more_info
|
|
|
|
respond_to do |format|
|
|
|
|
format.html # more_info.html.erb
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2012-09-02 09:57:34 +00:00
|
|
|
end
|