added filter to show only users logged in lately

This commit is contained in:
Absurdon 2017-07-02 18:34:19 +02:00
parent f06dfc025a
commit 0bf5e74c38
3 changed files with 8 additions and 2 deletions

View file

@ -3,7 +3,11 @@ class UsersController < ApplicationController
respond_to :html, :js
def index
@users = User.search(params[:search]).paginate(per_page: 40, page: params[:page])
if params[:filter] == 'lately'
@users = User.search(params[:search]).lately.paginate(per_page: 40, page: params[:page])
else
@users = User.search(params[:search]).paginate(per_page: 40, page: params[:page])
end
end
def show

View file

@ -1,5 +1,6 @@
<h1 class="title">Listing Users</h1>
<p><%= User.lately.count %> players have signed in within the past 30 days.</p>
<%= link_to 'Show them', params.merge(filter: 'lately'), class: 'button' %><br><br><br>
<p>Search for users by name or Steam ID:</p>

View file

@ -11,7 +11,7 @@
#
# It's strongly recommended to check this file into your version control system.
ActiveRecord::Schema.define(:version => 20170612182124) do
ActiveRecord::Schema.define(:version => 20170702150454) do
create_table "admin_requests", :force => true do |t|
t.string "addr"
@ -872,6 +872,7 @@ ActiveRecord::Schema.define(:version => 20170612182124) do
end
add_index "users", ["email"], :name => "index_users_on_email"
add_index "users", ["lastvisit"], :name => "index_users_on_lastvisit"
add_index "users", ["password"], :name => "index_users_on_password"
add_index "users", ["team_id"], :name => "index_users_on_team_id"
add_index "users", ["username"], :name => "index_users_on_username"