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,72 +1,74 | |||
|
1 | 1 | class ReportController < ApplicationController |
|
2 | 2 | |
|
3 | 3 | before_filter :admin_authorization, only: [:login_stat,:submission_stat] |
|
4 | 4 | before_filter(only: [:problem_hof]) { |c| |
|
5 | 5 | return false unless authenticate |
|
6 | 6 | |
|
7 | 7 | if GraderConfiguration["right.user_view_submission"] |
|
8 | 8 | return true; |
|
9 | 9 | end |
|
10 | 10 | |
|
11 | 11 | admin_authorization |
|
12 | 12 | } |
|
13 | 13 | |
|
14 | 14 | def login_stat |
|
15 | 15 | @logins = Array.new |
|
16 | 16 | |
|
17 | 17 | date_and_time = '%Y-%m-%d %H:%M' |
|
18 | 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 | 21 | rescue |
|
21 | 22 | @since_time = DateTime.new(1000,1,1) |
|
22 | 23 | end |
|
23 | 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 | 27 | rescue |
|
26 | 28 | @until_time = DateTime.new(3000,1,1) |
|
27 | 29 | end |
|
28 | 30 | |
|
29 | 31 | User.all.each do |user| |
|
30 | 32 | @logins << { id: user.id, |
|
31 | 33 | login: user.login, |
|
32 | 34 | full_name: user.full_name, |
|
33 | 35 | count: Login.where("user_id = ? AND created_at >= ? AND created_at <= ?", |
|
34 | 36 | user.id,@since_time,@until_time) |
|
35 | 37 | .count(:id), |
|
36 | 38 | min: Login.where("user_id = ? AND created_at >= ? AND created_at <= ?", |
|
37 | 39 | user.id,@since_time,@until_time) |
|
38 | 40 | .minimum(:created_at), |
|
39 | 41 | max: Login.where("user_id = ? AND created_at >= ? AND created_at <= ?", |
|
40 | 42 | user.id,@since_time,@until_time) |
|
41 | 43 | .maximum(:created_at), |
|
42 | 44 | ip: Login.where("user_id = ? AND created_at >= ? AND created_at <= ?", |
|
43 | 45 | user.id,@since_time,@until_time) |
|
44 | 46 | .select(:ip_address).uniq |
|
45 | 47 | |
|
46 | 48 | } |
|
47 | 49 | end |
|
48 | 50 | end |
|
49 | 51 | |
|
50 | 52 | def submission_stat |
|
51 | 53 | |
|
52 | 54 | date_and_time = '%Y-%m-%d %H:%M' |
|
53 | 55 | begin |
|
54 | 56 | @since_time = DateTime.strptime(params[:since_datetime],date_and_time) |
|
55 | 57 | rescue |
|
56 | 58 | @since_time = DateTime.new(1000,1,1) |
|
57 | 59 | end |
|
58 | 60 | begin |
|
59 | 61 | @until_time = DateTime.strptime(params[:until_datetime],date_and_time) |
|
60 | 62 | rescue |
|
61 | 63 | @until_time = DateTime.new(3000,1,1) |
|
62 | 64 | end |
|
63 | 65 | |
|
64 | 66 | @submissions = {} |
|
65 | 67 | |
|
66 | 68 | User.find_each do |user| |
|
67 | 69 | @submissions[user.id] = { login: user.login, full_name: user.full_name, count: 0, sub: { } } |
|
68 | 70 | end |
|
69 | 71 | |
|
70 | 72 | Submission.where("submitted_at >= ? AND submitted_at <= ?",@since_time,@until_time).find_each do |s| |
|
71 | 73 | if @submissions[s.user_id] |
|
72 | 74 | if not @submissions[s.user_id][:sub].has_key?(s.problem_id) |
You need to be logged in to leave comments.
Login now