Description:
add submission report
Commit status:
[Not Reviewed]
References:
Diff options:
Comments:
0 Commit comments
0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
r413:889d5737bb5f - - 6 files changed: 118 inserted, 23 deleted
@@ -0,0 +1,6 | |||
|
1 | + | |
|
2 | + .task-menu | |
|
3 | + Reports | |
|
4 | + %br/ | |
|
5 | + = link_to '[Submission]', :action => 'submission_stat' | |
|
6 | + = link_to '[Login]', :action => 'login_stat' |
@@ -0,0 +1,41 | |||
|
1 | + - content_for :header do | |
|
2 | + = javascript_include_tag 'new' | |
|
3 | + | |
|
4 | + %script{:type=>"text/javascript"} | |
|
5 | + $(function () { | |
|
6 | + $('#since_datetime').datetimepicker({ showButtonPanel: true, dateFormat: "yy-mm-dd", controlType: "slider"} ); | |
|
7 | + $('#until_datetime').datetimepicker({ showButtonPanel: true, dateFormat: "yy-mm-dd", controlType: "slider"} ); | |
|
8 | + }); | |
|
9 | + | |
|
10 | + | |
|
11 | + %h1 Login status | |
|
12 | + | |
|
13 | + | |
|
14 | + | |
|
15 | + | |
|
16 | + =render partial: 'report_menu' | |
|
17 | + =render partial: 'date_range', locals: {param_text: 'Submission date range:', title: 'Query submission stat in the range' } | |
|
18 | + | |
|
19 | + %table.info | |
|
20 | + %thead | |
|
21 | + %tr.info-head | |
|
22 | + %th login | |
|
23 | + %th full name | |
|
24 | + %th total submissions | |
|
25 | + %th submissions | |
|
26 | + %tbody | |
|
27 | + - @submissions.each do |user_id,data| | |
|
28 | + %tr{class: cycle('info-even','info-odd')} | |
|
29 | + %td= data[:login] | |
|
30 | + %td= data[:full_name] | |
|
31 | + %td= data[:count] | |
|
32 | + %td | |
|
33 | + - data[:sub].each do |prob_id,sub_data| | |
|
34 | + = "#{sub_data[:prob_name]}: [" | |
|
35 | + - st = [] | |
|
36 | + - sub_data[:sub_ids].each do |id| | |
|
37 | + - st << link_to(id, controller: 'graders' , action: 'submission', id: id) | |
|
38 | + = raw st.join ', ' | |
|
39 | + = ']' | |
|
40 | + %br/ | |
|
41 | + |
@@ -1,18 +1,70 | |||
|
1 | 1 | class ReportController < ApplicationController |
|
2 | 2 | def login_stat |
|
3 | 3 | @logins = Array.new |
|
4 | - login = Login.all | |
|
5 | 4 | |
|
6 |
- date_and_time = '% |
|
|
7 | - since_time = strptime(params[:since_datetime],date_and_time) | |
|
8 |
- |
|
|
5 | + date_and_time = '%Y-%m-%d %H:%M' | |
|
6 | + begin | |
|
7 | + @since_time = DateTime.strptime(params[:since_datetime],date_and_time) | |
|
8 | + rescue | |
|
9 | + @since_time = DateTime.new(1000,1,1) | |
|
10 | + end | |
|
11 | + begin | |
|
12 | + @until_time = DateTime.strptime(params[:until_datetime],date_and_time) | |
|
13 | + rescue | |
|
14 | + @until_time = DateTime.new(3000,1,1) | |
|
15 | + end | |
|
9 | 16 | |
|
10 | 17 | User.all.each do |user| |
|
11 | 18 | @logins << { login: user.login, |
|
12 | 19 | full_name: user.full_name, |
|
13 |
- count: Login.where(user_id |
|
|
14 | - min: Login.where(user_id: user.id).maximum(:created_at), | |
|
15 | - max: Login.where(user_id: user.id).minimum(:created_at) } | |
|
20 | + count: Login.where("user_id = ? AND created_at >= ? AND created_at <= ?", | |
|
21 | + user.id,@since_time,@until_time) | |
|
22 | + .count(:id), | |
|
23 | + min: Login.where("user_id = ? AND created_at >= ? AND created_at <= ?", | |
|
24 | + user.id,@since_time,@until_time) | |
|
25 | + .minimum(:created_at), | |
|
26 | + max: Login.where("user_id = ? AND created_at >= ? AND created_at <= ?", | |
|
27 | + user.id,@since_time,@until_time) | |
|
28 | + .maximum(:created_at) | |
|
29 | + } | |
|
30 | + end | |
|
31 | + end | |
|
32 | + | |
|
33 | + def submission_stat | |
|
34 | + | |
|
35 | + date_and_time = '%Y-%m-%d %H:%M' | |
|
36 | + begin | |
|
37 | + @since_time = DateTime.strptime(params[:since_datetime],date_and_time) | |
|
38 | + rescue | |
|
39 | + @since_time = DateTime.new(1000,1,1) | |
|
40 | + end | |
|
41 | + begin | |
|
42 | + @until_time = DateTime.strptime(params[:until_datetime],date_and_time) | |
|
43 | + rescue | |
|
44 | + @until_time = DateTime.new(3000,1,1) | |
|
45 | + end | |
|
46 | + | |
|
47 | + @submissions = {} | |
|
48 | + | |
|
49 | + User.find_each do |user| | |
|
50 | + @submissions[user.id] = { login: user.login, full_name: user.full_name, count: 0, sub: { } } | |
|
51 | + end | |
|
52 | + | |
|
53 | + Submission.where("submitted_at >= ? AND submitted_at <= ?",@since_time,@until_time).find_each do |s| | |
|
54 | + if not @submissions[s.user_id][:sub].has_key?(s.problem_id) | |
|
55 | + a = nil | |
|
56 | + begin | |
|
57 | + a = Problem.find(s.problem_id) | |
|
58 | + rescue | |
|
59 | + a = nil | |
|
60 | + end | |
|
61 | + @submissions[s.user_id][:sub][s.problem_id] = | |
|
62 | + { prob_name: (a ? a.full_name : '(NULL)'), | |
|
63 | + sub_ids: [s.id] } | |
|
64 | + else | |
|
65 | + @submissions[s.user_id][:sub][s.problem_id][:sub_ids] << s.id | |
|
66 | + end | |
|
67 | + @submissions[s.user_id][:count] += 1 | |
|
16 | 68 | end |
|
17 | 69 | end |
|
18 | 70 | end |
@@ -1,19 +1,23 | |||
|
1 | 1 | |
|
2 | 2 | = form_tag({session: :url }) do |
|
3 | 3 | .submitbox |
|
4 | 4 | %table |
|
5 | 5 | %tr |
|
6 |
- %td{colspan: 6, style: 'font-weight: bold'} |
|
|
6 | + %td{colspan: 6, style: 'font-weight: bold'}= title | |
|
7 | 7 | %tr |
|
8 | 8 | %td{style: 'width: 120px; font-weight: bold'}= param_text |
|
9 | 9 | %td{align: 'right'} since: |
|
10 | 10 | %td= text_field_tag 'since_datetime' |
|
11 | 11 | %tr |
|
12 | 12 | %td |
|
13 | 13 | %td{align: 'right'} until: |
|
14 | 14 | %td= text_field_tag 'until_datetime' |
|
15 | 15 | %tr |
|
16 | 16 | %td |
|
17 | 17 | %td |
|
18 | + %td Blank mean no condition | |
|
19 | + %tr | |
|
20 | + %td | |
|
21 | + %td | |
|
18 | 22 | %td= submit_tag 'query' |
|
19 | 23 |
@@ -1,44 +1,33 | |||
|
1 | 1 | - content_for :header do |
|
2 | 2 | = javascript_include_tag 'new' |
|
3 | 3 | |
|
4 | 4 | %script{:type=>"text/javascript"} |
|
5 | 5 | $(function () { |
|
6 | 6 | $('#since_datetime').datetimepicker({ showButtonPanel: true, dateFormat: "yy-mm-dd", controlType: "slider"} ); |
|
7 | 7 | $('#until_datetime').datetimepicker({ showButtonPanel: true, dateFormat: "yy-mm-dd", controlType: "slider"} ); |
|
8 | 8 | }); |
|
9 | 9 | |
|
10 | 10 | |
|
11 | 11 | %h1 Login status |
|
12 | 12 | |
|
13 | 13 | |
|
14 | - | |
|
15 | - .task-menu | |
|
16 | - Reports | |
|
17 | - %br/ | |
|
18 | - = link_to '[Submission]', :action => 'submit_stat' | |
|
19 | - = link_to '[Login]', :action => 'login_stat' | |
|
20 | - | |
|
21 | - | |
|
22 | - =render partial: 'date_range', locals: {param_text: 'Submission range:' } | |
|
23 | - | |
|
24 | - hahaha | |
|
25 | - | |
|
26 | - =params[:since_datetime] | |
|
14 | + =render partial: 'report_menu' | |
|
15 | + =render partial: 'date_range', locals: {param_text: 'Login date range:', title: 'Query login stat in the range' } | |
|
27 | 16 | |
|
28 | 17 | %table.info |
|
29 | 18 | %thead |
|
30 | 19 | %tr.info-head |
|
31 | 20 | %th login |
|
32 | 21 | %th full name |
|
33 | 22 | %th login count |
|
34 | 23 | %th earliest |
|
35 | 24 | %th latest |
|
36 | 25 | %tbody |
|
37 | 26 | - @logins.each do |l| |
|
38 | 27 | %tr{class: cycle('info-even','info-odd')} |
|
39 | 28 | %td= l[:login] |
|
40 | 29 | %td= l[:full_name] |
|
41 | 30 | %td= l[:count] |
|
42 | - %td= l[:min] | |
|
43 | - %td= l[:max] | |
|
31 | + %td= l[:min] ? l[:min].in_time_zone.strftime('%Y-%m-%d %H:%M') : '' | |
|
32 | + %td= l[:max] ? l[:max].in_time_zone.strftime('%Y-%m-%d %H:%M') : '' | |
|
44 | 33 |
@@ -128,96 +128,99 | |||
|
128 | 128 | end |
|
129 | 129 | |
|
130 | 130 | add_index "rights_roles", ["role_id"], :name => "index_rights_roles_on_role_id" |
|
131 | 131 | |
|
132 | 132 | create_table "roles", :force => true do |t| |
|
133 | 133 | t.string "name" |
|
134 | 134 | end |
|
135 | 135 | |
|
136 | 136 | create_table "roles_users", :id => false, :force => true do |t| |
|
137 | 137 | t.integer "role_id" |
|
138 | 138 | t.integer "user_id" |
|
139 | 139 | end |
|
140 | 140 | |
|
141 | 141 | add_index "roles_users", ["user_id"], :name => "index_roles_users_on_user_id" |
|
142 | 142 | |
|
143 | 143 | create_table "sessions", :force => true do |t| |
|
144 | 144 | t.string "session_id" |
|
145 | 145 | t.text "data" |
|
146 | 146 | t.datetime "updated_at" |
|
147 | 147 | end |
|
148 | 148 | |
|
149 | 149 | add_index "sessions", ["session_id"], :name => "index_sessions_on_session_id" |
|
150 | 150 | add_index "sessions", ["updated_at"], :name => "index_sessions_on_updated_at" |
|
151 | 151 | |
|
152 | 152 | create_table "sites", :force => true do |t| |
|
153 | 153 | t.string "name" |
|
154 | 154 | t.boolean "started" |
|
155 | 155 | t.datetime "start_time" |
|
156 | 156 | t.datetime "created_at", :null => false |
|
157 | 157 | t.datetime "updated_at", :null => false |
|
158 | 158 | t.integer "country_id" |
|
159 | 159 | t.string "password" |
|
160 | 160 | end |
|
161 | 161 | |
|
162 | 162 | create_table "submissions", :force => true do |t| |
|
163 | 163 | t.integer "user_id" |
|
164 | 164 | t.integer "problem_id" |
|
165 | 165 | t.integer "language_id" |
|
166 | 166 | t.text "source" |
|
167 | 167 | t.binary "binary" |
|
168 | 168 | t.datetime "submitted_at" |
|
169 | 169 | t.datetime "compiled_at" |
|
170 | 170 | t.text "compiler_message" |
|
171 | 171 | t.datetime "graded_at" |
|
172 | 172 | t.integer "points" |
|
173 | 173 | t.text "grader_comment" |
|
174 | 174 | t.integer "number" |
|
175 | 175 | t.string "source_filename" |
|
176 | + t.float "max_runtime" | |
|
177 | + t.integer "peak_memory" | |
|
178 | + t.integer "effective_code_length" | |
|
176 | 179 | end |
|
177 | 180 | |
|
178 | 181 | add_index "submissions", ["user_id", "problem_id", "number"], :name => "index_submissions_on_user_id_and_problem_id_and_number", :unique => true |
|
179 | 182 | add_index "submissions", ["user_id", "problem_id"], :name => "index_submissions_on_user_id_and_problem_id" |
|
180 | 183 | |
|
181 | 184 | create_table "tasks", :force => true do |t| |
|
182 | 185 | t.integer "submission_id" |
|
183 | 186 | t.datetime "created_at" |
|
184 | 187 | t.integer "status" |
|
185 | 188 | t.datetime "updated_at" |
|
186 | 189 | end |
|
187 | 190 | |
|
188 | 191 | create_table "test_pairs", :force => true do |t| |
|
189 | 192 | t.integer "problem_id" |
|
190 | 193 | t.text "input", :limit => 16777215 |
|
191 | 194 | t.text "solution", :limit => 16777215 |
|
192 | 195 | t.datetime "created_at", :null => false |
|
193 | 196 | t.datetime "updated_at", :null => false |
|
194 | 197 | end |
|
195 | 198 | |
|
196 | 199 | create_table "test_requests", :force => true do |t| |
|
197 | 200 | t.integer "user_id" |
|
198 | 201 | t.integer "problem_id" |
|
199 | 202 | t.integer "submission_id" |
|
200 | 203 | t.string "input_file_name" |
|
201 | 204 | t.string "output_file_name" |
|
202 | 205 | t.string "running_stat" |
|
203 | 206 | t.integer "status" |
|
204 | 207 | t.datetime "updated_at", :null => false |
|
205 | 208 | t.datetime "submitted_at" |
|
206 | 209 | t.datetime "compiled_at" |
|
207 | 210 | t.text "compiler_message" |
|
208 | 211 | t.datetime "graded_at" |
|
209 | 212 | t.string "grader_comment" |
|
210 | 213 | t.datetime "created_at", :null => false |
|
211 | 214 | t.float "running_time" |
|
212 | 215 | t.string "exit_status" |
|
213 | 216 | t.integer "memory_usage" |
|
214 | 217 | end |
|
215 | 218 | |
|
216 | 219 | add_index "test_requests", ["user_id", "problem_id"], :name => "index_test_requests_on_user_id_and_problem_id" |
|
217 | 220 | |
|
218 | 221 | create_table "user_contest_stats", :force => true do |t| |
|
219 | 222 | t.integer "user_id" |
|
220 | 223 | t.datetime "started_at" |
|
221 | 224 | t.datetime "created_at", :null => false |
|
222 | 225 | t.datetime "updated_at", :null => false |
|
223 | 226 | t.boolean "forced_logout" |
You need to be logged in to leave comments.
Login now