Description:
fix submission report, when submissions belong no non-existing user
Commit status:
[Not Reviewed]
References:
Comments:
0 Commit comments 0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
Add another comment

r415:8de9a512ac85 - - 1 file changed: 2 inserted, 0 deleted

@@ -42,29 +42,31
42 @until_time = DateTime.strptime(params[:until_datetime],date_and_time)
42 @until_time = DateTime.strptime(params[:until_datetime],date_and_time)
43 rescue
43 rescue
44 @until_time = DateTime.new(3000,1,1)
44 @until_time = DateTime.new(3000,1,1)
45 end
45 end
46
46
47 @submissions = {}
47 @submissions = {}
48
48
49 User.find_each do |user|
49 User.find_each do |user|
50 @submissions[user.id] = { login: user.login, full_name: user.full_name, count: 0, sub: { } }
50 @submissions[user.id] = { login: user.login, full_name: user.full_name, count: 0, sub: { } }
51 end
51 end
52
52
53 Submission.where("submitted_at >= ? AND submitted_at <= ?",@since_time,@until_time).find_each do |s|
53 Submission.where("submitted_at >= ? AND submitted_at <= ?",@since_time,@until_time).find_each do |s|
54 + if @submissions[s.user_id]
54 if not @submissions[s.user_id][:sub].has_key?(s.problem_id)
55 if not @submissions[s.user_id][:sub].has_key?(s.problem_id)
55 a = nil
56 a = nil
56 begin
57 begin
57 a = Problem.find(s.problem_id)
58 a = Problem.find(s.problem_id)
58 rescue
59 rescue
59 a = nil
60 a = nil
60 end
61 end
61 @submissions[s.user_id][:sub][s.problem_id] =
62 @submissions[s.user_id][:sub][s.problem_id] =
62 { prob_name: (a ? a.full_name : '(NULL)'),
63 { prob_name: (a ? a.full_name : '(NULL)'),
63 sub_ids: [s.id] }
64 sub_ids: [s.id] }
64 else
65 else
65 @submissions[s.user_id][:sub][s.problem_id][:sub_ids] << s.id
66 @submissions[s.user_id][:sub][s.problem_id][:sub_ids] << s.id
66 end
67 end
67 @submissions[s.user_id][:count] += 1
68 @submissions[s.user_id][:count] += 1
68 end
69 end
69 end
70 end
70 end
71 end
72 + end
You need to be logged in to leave comments. Login now