Description:
fix date time
Commit status:
[Not Reviewed]
References:
Diff options:
Comments:
0 Commit comments
0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
r443:2d5e2b9fa726 - - 1 file changed: 4 inserted, 2 deleted
@@ -1,48 +1,50 | |||||
|
1 | class ReportController < ApplicationController |
|
1 | class ReportController < ApplicationController |
|
2 |
|
2 | ||
|
3 | before_filter :admin_authorization, only: [:login_stat,:submission_stat] |
|
3 | before_filter :admin_authorization, only: [:login_stat,:submission_stat] |
|
4 | before_filter(only: [:problem_hof]) { |c| |
|
4 | before_filter(only: [:problem_hof]) { |c| |
|
5 | return false unless authenticate |
|
5 | return false unless authenticate |
|
6 |
|
6 | ||
|
7 | if GraderConfiguration["right.user_view_submission"] |
|
7 | if GraderConfiguration["right.user_view_submission"] |
|
8 | return true; |
|
8 | return true; |
|
9 | end |
|
9 | end |
|
10 |
|
10 | ||
|
11 | admin_authorization |
|
11 | admin_authorization |
|
12 | } |
|
12 | } |
|
13 |
|
13 | ||
|
14 | def login_stat |
|
14 | def login_stat |
|
15 | @logins = Array.new |
|
15 | @logins = Array.new |
|
16 |
|
16 | ||
|
17 | date_and_time = '%Y-%m-%d %H:%M' |
|
17 | date_and_time = '%Y-%m-%d %H:%M' |
|
18 | begin |
|
18 | begin |
|
19 | - @since_time = DateTime.strptime(params[:since_datetime],date_and_time) |
|
19 | + md = params[:since_datetime].match(/(\d+)-(\d+)-(\d+) (\d+):(\d+)/) |
|
|
20 | + @since_time = Time.zone.local(md[1].to_i,md[2].to_i,md[3].to_i,md[4].to_i,md[5].to_i) | ||
|
20 | rescue |
|
21 | rescue |
|
21 | @since_time = DateTime.new(1000,1,1) |
|
22 | @since_time = DateTime.new(1000,1,1) |
|
22 | end |
|
23 | end |
|
23 | begin |
|
24 | begin |
|
24 | - @until_time = DateTime.strptime(params[:until_datetime],date_and_time) |
|
25 | + md = params[:until_datetime].match(/(\d+)-(\d+)-(\d+) (\d+):(\d+)/) |
|
|
26 | + @until_time = Time.zone.local(md[1].to_i,md[2].to_i,md[3].to_i,md[4].to_i,md[5].to_i) | ||
|
25 | rescue |
|
27 | rescue |
|
26 | @until_time = DateTime.new(3000,1,1) |
|
28 | @until_time = DateTime.new(3000,1,1) |
|
27 | end |
|
29 | end |
|
28 |
|
30 | ||
|
29 | User.all.each do |user| |
|
31 | User.all.each do |user| |
|
30 | @logins << { id: user.id, |
|
32 | @logins << { id: user.id, |
|
31 | login: user.login, |
|
33 | login: user.login, |
|
32 | full_name: user.full_name, |
|
34 | full_name: user.full_name, |
|
33 | count: Login.where("user_id = ? AND created_at >= ? AND created_at <= ?", |
|
35 | count: Login.where("user_id = ? AND created_at >= ? AND created_at <= ?", |
|
34 | user.id,@since_time,@until_time) |
|
36 | user.id,@since_time,@until_time) |
|
35 | .count(:id), |
|
37 | .count(:id), |
|
36 | min: Login.where("user_id = ? AND created_at >= ? AND created_at <= ?", |
|
38 | min: Login.where("user_id = ? AND created_at >= ? AND created_at <= ?", |
|
37 | user.id,@since_time,@until_time) |
|
39 | user.id,@since_time,@until_time) |
|
38 | .minimum(:created_at), |
|
40 | .minimum(:created_at), |
|
39 | max: Login.where("user_id = ? AND created_at >= ? AND created_at <= ?", |
|
41 | max: Login.where("user_id = ? AND created_at >= ? AND created_at <= ?", |
|
40 | user.id,@since_time,@until_time) |
|
42 | user.id,@since_time,@until_time) |
|
41 | .maximum(:created_at), |
|
43 | .maximum(:created_at), |
|
42 | ip: Login.where("user_id = ? AND created_at >= ? AND created_at <= ?", |
|
44 | ip: Login.where("user_id = ? AND created_at >= ? AND created_at <= ?", |
|
43 | user.id,@since_time,@until_time) |
|
45 | user.id,@since_time,@until_time) |
|
44 | .select(:ip_address).uniq |
|
46 | .select(:ip_address).uniq |
|
45 |
|
47 | ||
|
46 | } |
|
48 | } |
|
47 | end |
|
49 | end |
|
48 | end |
|
50 | end |
You need to be logged in to leave comments.
Login now