From c61b8ac8d4bf727fab35f3277fcbb19f84b49a24 Mon Sep 17 00:00:00 2001 From: Will Bradley Date: Thu, 29 Aug 2013 02:50:05 -0700 Subject: [PATCH] Adding recent users report --- app/controllers/users_controller.rb | 3 +- app/views/users/activity.html.erb | 52 ++++++++++++++++++++++++++--- 2 files changed, 49 insertions(+), 6 deletions(-) diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 5ddb971..a9ba487 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -40,7 +40,8 @@ class UsersController < ApplicationController # Recent user activity def activity - @users = User.where(:last_sign_in_at => 1.month.ago..Date.today) + @user_logins = User.where(:last_sign_in_at => 1.month.ago..Date.today) + @new_users = User.where(:created_at => 3.months.ago..Date.today) end # GET /users/1 diff --git a/app/views/users/activity.html.erb b/app/views/users/activity.html.erb index dd2aee8..910ba04 100644 --- a/app/views/users/activity.html.erb +++ b/app/views/users/activity.html.erb @@ -1,18 +1,62 @@

Recent User Activity

+

New Users

+ + + + + + + + + +<% if !@new_users.blank? %> + <% @new_users.sort_by(&:created_at).reverse!.each do |user| %> + + + + + + + + <% end %> +<% end %> +
NameMember LevelAccount CreatedWaiverOrientationPayment
<%= link_to user.name, user %><%= user.member_level_string %><% if user.created_at.present? %> + <%= distance_of_time_in_words(DateTime.now, user.created_at.to_date)+" ago" %> + <% else %> + × + <% end %><% if user.waiver.present? %> + <%= distance_of_time_in_words(DateTime.now, user.waiver.to_date)+" ago" %> + <% else %> + × + <% end %><% if user.orientation.present? %> + <%= distance_of_time_in_words(DateTime.now, user.orientation.to_date)+" ago" %> + <% else %> + × + <% end %><% if user.payments.present? %> + <%= distance_of_time_in_words(Date.today, user.payments.maximum(:date))+" ago" %> + <% else %> + × + <% end %>
+ +

Logins

+ + + - -<% if !@users.blank? %> - <% @users.sort_by(&:current_sign_in_at).reverse!.each do |user| %> +<% if !@user_logins.blank? %> + <% @user_logins.sort_by(&:current_sign_in_at).reverse!.each do |user| %> - - <% end %> <% end %>
Name Current Sign In Last Sign In Sign In CountName Account Created
<%= link_to user.name, user %> <%= distance_of_time_in_words DateTime.now, user.current_sign_in_at %> ago <% if user.last_sign_in_at != user.current_sign_in_at %> @@ -20,9 +64,7 @@ <% end %> <%= user.sign_in_count %> times<%= link_to user.name, user %> <%= distance_of_time_in_words DateTime.now, user.created_at %> ago<%= link_to 'Edit', edit_user_path(user) if can? :update, user %>