show count for users signed in the last 30 days on users page

This commit is contained in:
Absurdon 2017-07-02 17:14:07 +02:00
parent 3edf8cc5e7
commit f06dfc025a
3 changed files with 8 additions and 0 deletions

View file

@ -99,6 +99,8 @@ class User < ActiveRecord::Base
:conditions => "bans.id IS NOT NULL"
scope :idle,
:conditions => ["lastvisit < ?", 30.minutes.ago.utc]
scope :lately,
:conditions => ["lastvisit > ?", 30.days.ago.utc]
before_validation :update_password

View file

@ -1,4 +1,5 @@
<h1 class="title">Listing Users</h1>
<p><%= User.lately.count %> players have signed in within the past 30 days.</p>
<p>Search for users by name or Steam ID:</p>

View file

@ -0,0 +1,5 @@
class AddLastvisitIndexToUsers < ActiveRecord::Migration
def change
add_index :users, :lastvisit
end
end