Started on date filtering for stats

This commit is contained in:
cole m alban 2017-04-04 12:20:22 -04:00
parent 0ffa44897a
commit 8e2d357c3d
2 changed files with 9 additions and 4 deletions

View File

@ -6,15 +6,12 @@ class SessionsController < Devise::RegistrationsController
end
def create
puts "NOW IN CREATE"
params = sign_in_params
@user = User.find_by(email: params[:email])
if @user == nil || !@user.valid_password?(params[:password])
redirect_to "/signin"
return
end
super
#Do we need this code below? It was never running before
resource = warden.authenticate!(:scope => :user)
sign_in(:user, resource)
if !current_user.admin

View File

@ -1,6 +1,14 @@
class StatisticsController < ApplicationController
def index
puts params.inspect
if params[:from_date] != nil && params[:to_date] != nil
from_date = Date.parse params[:from_date]
to_date = Date.parse params[:to_date]
runs = Run.where(:runDate => from_date.beginning_of_day..to_date.end_of_day)
puts runs.inspect
else
runs = Run.all
puts runs.inspect
end
end
end