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 |
@@ -1,242 +1,245 | |||
|
1 | 1 | # encoding: UTF-8 |
|
2 | 2 | # This file is auto-generated from the current state of the database. Instead |
|
3 | 3 | # of editing this file, please use the migrations feature of Active Record to |
|
4 | 4 | # incrementally modify your database, and then regenerate this schema definition. |
|
5 | 5 | # |
|
6 | 6 | # Note that this schema.rb definition is the authoritative source for your |
|
7 | 7 | # database schema. If you need to create the application database on another |
|
8 | 8 | # system, you should be using db:schema:load, not running all the migrations |
|
9 | 9 | # from scratch. The latter is a flawed and unsustainable approach (the more migrations |
|
10 | 10 | # you'll amass, the slower it'll run and the greater likelihood for issues). |
|
11 | 11 | # |
|
12 | 12 | # It's strongly recommended to check this file into your version control system. |
|
13 | 13 | |
|
14 | 14 | ActiveRecord::Schema.define(:version => 20140826095949) do |
|
15 | 15 | |
|
16 | 16 | create_table "announcements", :force => true do |t| |
|
17 | 17 | t.string "author" |
|
18 | 18 | t.text "body" |
|
19 | 19 | t.boolean "published" |
|
20 | 20 | t.datetime "created_at", :null => false |
|
21 | 21 | t.datetime "updated_at", :null => false |
|
22 | 22 | t.boolean "frontpage", :default => false |
|
23 | 23 | t.boolean "contest_only", :default => false |
|
24 | 24 | t.string "title" |
|
25 | 25 | t.string "notes" |
|
26 | 26 | end |
|
27 | 27 | |
|
28 | 28 | create_table "contests", :force => true do |t| |
|
29 | 29 | t.string "title" |
|
30 | 30 | t.boolean "enabled" |
|
31 | 31 | t.datetime "created_at", :null => false |
|
32 | 32 | t.datetime "updated_at", :null => false |
|
33 | 33 | t.string "name" |
|
34 | 34 | end |
|
35 | 35 | |
|
36 | 36 | create_table "contests_problems", :id => false, :force => true do |t| |
|
37 | 37 | t.integer "contest_id" |
|
38 | 38 | t.integer "problem_id" |
|
39 | 39 | end |
|
40 | 40 | |
|
41 | 41 | create_table "contests_users", :id => false, :force => true do |t| |
|
42 | 42 | t.integer "contest_id" |
|
43 | 43 | t.integer "user_id" |
|
44 | 44 | end |
|
45 | 45 | |
|
46 | 46 | create_table "countries", :force => true do |t| |
|
47 | 47 | t.string "name" |
|
48 | 48 | t.datetime "created_at", :null => false |
|
49 | 49 | t.datetime "updated_at", :null => false |
|
50 | 50 | end |
|
51 | 51 | |
|
52 | 52 | create_table "descriptions", :force => true do |t| |
|
53 | 53 | t.text "body" |
|
54 | 54 | t.boolean "markdowned" |
|
55 | 55 | t.datetime "created_at", :null => false |
|
56 | 56 | t.datetime "updated_at", :null => false |
|
57 | 57 | end |
|
58 | 58 | |
|
59 | 59 | create_table "grader_configurations", :force => true do |t| |
|
60 | 60 | t.string "key" |
|
61 | 61 | t.string "value_type" |
|
62 | 62 | t.string "value" |
|
63 | 63 | t.datetime "created_at", :null => false |
|
64 | 64 | t.datetime "updated_at", :null => false |
|
65 | 65 | t.text "description" |
|
66 | 66 | end |
|
67 | 67 | |
|
68 | 68 | create_table "grader_processes", :force => true do |t| |
|
69 | 69 | t.string "host", :limit => 20 |
|
70 | 70 | t.integer "pid" |
|
71 | 71 | t.string "mode" |
|
72 | 72 | t.boolean "active" |
|
73 | 73 | t.datetime "created_at", :null => false |
|
74 | 74 | t.datetime "updated_at", :null => false |
|
75 | 75 | t.integer "task_id" |
|
76 | 76 | t.string "task_type" |
|
77 | 77 | t.boolean "terminated" |
|
78 | 78 | end |
|
79 | 79 | |
|
80 | 80 | add_index "grader_processes", ["host", "pid"], :name => "index_grader_processes_on_ip_and_pid" |
|
81 | 81 | |
|
82 | 82 | create_table "languages", :force => true do |t| |
|
83 | 83 | t.string "name", :limit => 10 |
|
84 | 84 | t.string "pretty_name" |
|
85 | 85 | t.string "ext", :limit => 10 |
|
86 | 86 | t.string "common_ext" |
|
87 | 87 | end |
|
88 | 88 | |
|
89 | 89 | create_table "logins", :force => true do |t| |
|
90 | 90 | t.string "user_id" |
|
91 | 91 | t.string "ip_address" |
|
92 | 92 | t.datetime "created_at", :null => false |
|
93 | 93 | t.datetime "updated_at", :null => false |
|
94 | 94 | end |
|
95 | 95 | |
|
96 | 96 | create_table "messages", :force => true do |t| |
|
97 | 97 | t.integer "sender_id" |
|
98 | 98 | t.integer "receiver_id" |
|
99 | 99 | t.integer "replying_message_id" |
|
100 | 100 | t.text "body" |
|
101 | 101 | t.boolean "replied" |
|
102 | 102 | t.datetime "created_at", :null => false |
|
103 | 103 | t.datetime "updated_at", :null => false |
|
104 | 104 | end |
|
105 | 105 | |
|
106 | 106 | create_table "problems", :force => true do |t| |
|
107 | 107 | t.string "name", :limit => 30 |
|
108 | 108 | t.string "full_name" |
|
109 | 109 | t.integer "full_score" |
|
110 | 110 | t.date "date_added" |
|
111 | 111 | t.boolean "available" |
|
112 | 112 | t.string "url" |
|
113 | 113 | t.integer "description_id" |
|
114 | 114 | t.boolean "test_allowed" |
|
115 | 115 | t.boolean "output_only" |
|
116 | 116 | t.string "description_filename" |
|
117 | 117 | end |
|
118 | 118 | |
|
119 | 119 | create_table "rights", :force => true do |t| |
|
120 | 120 | t.string "name" |
|
121 | 121 | t.string "controller" |
|
122 | 122 | t.string "action" |
|
123 | 123 | end |
|
124 | 124 | |
|
125 | 125 | create_table "rights_roles", :id => false, :force => true do |t| |
|
126 | 126 | t.integer "right_id" |
|
127 | 127 | t.integer "role_id" |
|
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" |
|
224 | 227 | end |
|
225 | 228 | |
|
226 | 229 | create_table "users", :force => true do |t| |
|
227 | 230 | t.string "login", :limit => 50 |
|
228 | 231 | t.string "full_name" |
|
229 | 232 | t.string "hashed_password" |
|
230 | 233 | t.string "salt", :limit => 5 |
|
231 | 234 | t.string "alias" |
|
232 | 235 | t.string "email" |
|
233 | 236 | t.integer "site_id" |
|
234 | 237 | t.integer "country_id" |
|
235 | 238 | t.boolean "activated", :default => false |
|
236 | 239 | t.datetime "created_at" |
|
237 | 240 | t.datetime "updated_at" |
|
238 | 241 | end |
|
239 | 242 | |
|
240 | 243 | add_index "users", ["login"], :name => "index_users_on_login", :unique => true |
|
241 | 244 | |
|
242 | 245 | end |
You need to be logged in to leave comments.
Login now