Description:
fixed timing stat bug when used with single user mode
Commit status:
[Not Reviewed]
References:
Comments:
0 Commit comments 0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
Add another comment

r245:4658efe40e96 - - 2 files changed: 7 inserted, 1 deleted

@@ -1,25 +1,24
1 class LoginController < ApplicationController
1 class LoginController < ApplicationController
2
2
3 def index
3 def index
4 # show login screen
4 # show login screen
5 reset_session
5 reset_session
6 redirect_to :controller => 'main', :action => 'login'
6 redirect_to :controller => 'main', :action => 'login'
7 end
7 end
8
8
9 def login
9 def login
10 if user = User.authenticate(params[:login], params[:password])
10 if user = User.authenticate(params[:login], params[:password])
11 session[:user_id] = user.id
11 session[:user_id] = user.id
12 session[:admin] = user.admin?
12 session[:admin] = user.admin?
13 - UserContestStat.update_user_start_time(user)
14 redirect_to :controller => 'main', :action => 'list'
13 redirect_to :controller => 'main', :action => 'list'
15 else
14 else
16 flash[:notice] = 'Wrong password'
15 flash[:notice] = 'Wrong password'
17 redirect_to :controller => 'main', :action => 'login'
16 redirect_to :controller => 'main', :action => 'login'
18 end
17 end
19 end
18 end
20
19
21 def site_login
20 def site_login
22 begin
21 begin
23 site = Site.find(params[:login][:site_id])
22 site = Site.find(params[:login][:site_id])
24 rescue ActiveRecord::RecordNotFound
23 rescue ActiveRecord::RecordNotFound
25 site = nil
24 site = nil
@@ -1,17 +1,19
1 class MainController < ApplicationController
1 class MainController < ApplicationController
2
2
3 before_filter :authenticate, :except => [:index, :login]
3 before_filter :authenticate, :except => [:index, :login]
4 before_filter :check_viewability, :except => [:index, :login]
4 before_filter :check_viewability, :except => [:index, :login]
5
5
6 + append_before_filter :update_user_start_time, :except => [:index, :login]
7 +
6 # COMMENTED OUT: filter in each action instead
8 # COMMENTED OUT: filter in each action instead
7 # before_filter :verify_time_limit, :only => [:submit]
9 # before_filter :verify_time_limit, :only => [:submit]
8
10
9 verify :method => :post, :only => [:submit, :download_input, :submit_solution],
11 verify :method => :post, :only => [:submit, :download_input, :submit_solution],
10 :redirect_to => { :action => :index }
12 :redirect_to => { :action => :index }
11
13
12 # COMMENT OUT: only need when having high load
14 # COMMENT OUT: only need when having high load
13 # caches_action :index, :login
15 # caches_action :index, :login
14
16
15 # NOTE: This method is not actually needed, 'config/routes.rb' has
17 # NOTE: This method is not actually needed, 'config/routes.rb' has
16 # assigned action login as a default action.
18 # assigned action login as a default action.
17 def index
19 def index
@@ -446,14 +448,19
446 else
448 else
447 memory_used = -1
449 memory_used = -1
448 end
450 end
449
451
450 return {
452 return {
451 :msg => "#{run_stat}\n#{time_stat}",
453 :msg => "#{run_stat}\n#{time_stat}",
452 :running_time => seconds,
454 :running_time => seconds,
453 :exit_status => run_stat,
455 :exit_status => run_stat,
454 :memory_usage => memory_used
456 :memory_usage => memory_used
455 }
457 }
456 end
458 end
457
459
460 + def update_user_start_time
461 + user = User.find(session[:user_id])
462 + UserContestStat.update_user_start_time(user)
458 end
463 end
459
464
465 + end
466 +
You need to be logged in to leave comments. Login now