Description:
save point
Commit status:
[Not Reviewed]
References:
Comments:
0 Commit comments 0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
Add another comment

r423:abd08161c89d - - 1 file changed: 13 inserted, 0 deleted

@@ -1,51 +1,64
1 1 class ReportController < ApplicationController
2 2
3 3 before_filter :admin_authorization, only: [:login_stat,:submission_stat]
4 + before_filter(only: :problem_hof) { |c|
5 + user = User.find(session[:user_id]) if session[:user_id]
6 + if user==nil
7 + flash[:notice] = 'You have to login first'
8 + redirect_to :controller => 'main', :action => 'login'
9 + return false
10 + end
11 +
12 + unless GraderConfiguration["hall_of_fame_available"]
13 + flash[:notice] = 'You are not authorized to view the page you requested'
14 + redirect_to :controller => 'main', :action => 'login' unless GraderConfiguration[ "hall_of_fame_available" ]
15 + end
16 + }
4 17
5 18 def login_stat
6 19 @logins = Array.new
7 20
8 21 date_and_time = '%Y-%m-%d %H:%M'
9 22 begin
10 23 @since_time = DateTime.strptime(params[:since_datetime],date_and_time)
11 24 rescue
12 25 @since_time = DateTime.new(1000,1,1)
13 26 end
14 27 begin
15 28 @until_time = DateTime.strptime(params[:until_datetime],date_and_time)
16 29 rescue
17 30 @until_time = DateTime.new(3000,1,1)
18 31 end
19 32
20 33 User.all.each do |user|
21 34 @logins << { login: user.login,
22 35 full_name: user.full_name,
23 36 count: Login.where("user_id = ? AND created_at >= ? AND created_at <= ?",
24 37 user.id,@since_time,@until_time)
25 38 .count(:id),
26 39 min: Login.where("user_id = ? AND created_at >= ? AND created_at <= ?",
27 40 user.id,@since_time,@until_time)
28 41 .minimum(:created_at),
29 42 max: Login.where("user_id = ? AND created_at >= ? AND created_at <= ?",
30 43 user.id,@since_time,@until_time)
31 44 .maximum(:created_at)
32 45 }
33 46 end
34 47 end
35 48
36 49 def submission_stat
37 50
38 51 date_and_time = '%Y-%m-%d %H:%M'
39 52 begin
40 53 @since_time = DateTime.strptime(params[:since_datetime],date_and_time)
41 54 rescue
42 55 @since_time = DateTime.new(1000,1,1)
43 56 end
44 57 begin
45 58 @until_time = DateTime.strptime(params[:until_datetime],date_and_time)
46 59 rescue
47 60 @until_time = DateTime.new(3000,1,1)
48 61 end
49 62
50 63 @submissions = {}
51 64
You need to be logged in to leave comments. Login now