Description:
add login stat
Commit status:
[Not Reviewed]
References:
Diff options:
Comments:
0 Commit comments
0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
r410:1c14a43c4f1f - - 11 files changed: 115 inserted, 74 deleted
@@ -0,0 +1,3 | |||||
|
|
1 | + # Place all the behaviors and hooks related to the matching controller here. | ||
|
|
2 | + # All this logic will automatically be available in application.js. | ||
|
|
3 | + # You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/ |
@@ -0,0 +1,3 | |||||
|
|
1 | + // Place all the styles related to the report controller here. | ||
|
|
2 | + // They will automatically be included in application.css. | ||
|
|
3 | + // You can use Sass (SCSS) here: http://sass-lang.com/ |
@@ -0,0 +1,13 | |||||
|
|
1 | + class ReportController < ApplicationController | ||
|
|
2 | + def login_stat | ||
|
|
3 | + @logins = Array.new | ||
|
|
4 | + login = Login.all | ||
|
|
5 | + User.all.each do |user| | ||
|
|
6 | + @logins << { login: user.login, | ||
|
|
7 | + full_name: user.full_name, | ||
|
|
8 | + count: Login.where(user_id: user.id).count(:id), | ||
|
|
9 | + min: Login.where(user_id: user.id).maximum(:created_at), | ||
|
|
10 | + max: Login.where(user_id: user.id).minimum(:created_at) } | ||
|
|
11 | + end | ||
|
|
12 | + end | ||
|
|
13 | + end |
@@ -0,0 +1,3 | |||||
|
|
1 | + class Login < ActiveRecord::Base | ||
|
|
2 | + attr_accessible :ip_address, :logged_in_at, :user_id | ||
|
|
3 | + end |
@@ -0,0 +1,26 | |||||
|
|
1 | + %h1 Login status | ||
|
|
2 | + | ||
|
|
3 | + | ||
|
|
4 | + .task-menu | ||
|
|
5 | + Reports | ||
|
|
6 | + %br/ | ||
|
|
7 | + = link_to '[Submission]', :action => 'submit_stat' | ||
|
|
8 | + = link_to '[Login]', :action => 'login_stat' | ||
|
|
9 | + | ||
|
|
10 | + %table.info | ||
|
|
11 | + %thead | ||
|
|
12 | + %tr.info-head | ||
|
|
13 | + %th login | ||
|
|
14 | + %th full name | ||
|
|
15 | + %th login count | ||
|
|
16 | + %th earliest | ||
|
|
17 | + %th latest | ||
|
|
18 | + %tbody | ||
|
|
19 | + - @logins.each do |l| | ||
|
|
20 | + %tr{class: cycle('info-even','info-odd')} | ||
|
|
21 | + %td= l[:login] | ||
|
|
22 | + %td= l[:full_name] | ||
|
|
23 | + %td= l[:count] | ||
|
|
24 | + %td= l[:min] | ||
|
|
25 | + %td= l[:max] | ||
|
|
26 | + |
@@ -0,0 +1,10 | |||||
|
|
1 | + class CreateLogins < ActiveRecord::Migration | ||
|
|
2 | + def change | ||
|
|
3 | + create_table :logins do |t| | ||
|
|
4 | + t.string :user_id | ||
|
|
5 | + t.string :ip_address | ||
|
|
6 | + | ||
|
|
7 | + t.timestamps | ||
|
|
8 | + end | ||
|
|
9 | + end | ||
|
|
10 | + end |
@@ -0,0 +1,5 | |||||
|
|
1 | + require 'spec_helper' | ||
|
|
2 | + | ||
|
|
3 | + describe Login do | ||
|
|
4 | + pending "add some examples to (or delete) #{__FILE__}" | ||
|
|
5 | + end |
@@ -19,12 +19,15 | |||||
|
19 | contest_stat.forced_logout = false |
|
19 | contest_stat.forced_logout = false |
|
20 | contest_stat.save |
|
20 | contest_stat.save |
|
21 | end |
|
21 | end |
|
22 | end |
|
22 | end |
|
23 | end |
|
23 | end |
|
24 |
|
24 | ||
|
|
25 | + #save login information | ||
|
|
26 | + Login.create(user_id: user.id, ip_address: request.remote_ip) | ||
|
|
27 | + | ||
|
25 | redirect_to :controller => 'main', :action => 'list' |
|
28 | redirect_to :controller => 'main', :action => 'list' |
|
26 | else |
|
29 | else |
|
27 | flash[:notice] = 'Wrong password' |
|
30 | flash[:notice] = 'Wrong password' |
|
28 | redirect_to :controller => 'main', :action => 'login' |
|
31 | redirect_to :controller => 'main', :action => 'login' |
|
29 | end |
|
32 | end |
|
30 | end |
|
33 | end |
@@ -1,7 +1,11 | |||||
|
1 | CafeGrader::Application.routes.draw do |
|
1 | CafeGrader::Application.routes.draw do |
|
|
2 | + get "report/login" | ||
|
|
3 | + | ||
|
|
4 | + get "logins/list" | ||
|
|
5 | + | ||
|
2 | resources :contests |
|
6 | resources :contests |
|
3 |
|
7 | ||
|
4 | resources :announcements |
|
8 | resources :announcements |
|
5 | resources :sites |
|
9 | resources :sites |
|
6 |
|
10 | ||
|
7 | # The priority is based upon order of creation: |
|
11 | # The priority is based upon order of creation: |
@@ -8,39 +8,31 | |||||
|
8 | # system, you should be using db:schema:load, not running all the migrations |
|
8 | # system, you should be using db:schema:load, not running all the migrations |
|
9 | # from scratch. The latter is a flawed and unsustainable approach (the more migrations |
|
9 | # from scratch. The latter is a flawed and unsustainable approach (the more migrations |
|
10 | # you'll amass, the slower it'll run and the greater likelihood for issues). |
|
10 | # you'll amass, the slower it'll run and the greater likelihood for issues). |
|
11 | # |
|
11 | # |
|
12 | # It's strongly recommended to check this file into your version control system. |
|
12 | # It's strongly recommended to check this file into your version control system. |
|
13 |
|
13 | ||
|
14 |
- ActiveRecord::Schema.define(:version => 201 |
|
14 | + ActiveRecord::Schema.define(:version => 20140826095949) do |
|
15 |
|
15 | ||
|
16 | create_table "announcements", :force => true do |t| |
|
16 | create_table "announcements", :force => true do |t| |
|
17 | t.string "author" |
|
17 | t.string "author" |
|
18 | t.text "body" |
|
18 | t.text "body" |
|
19 | t.boolean "published" |
|
19 | t.boolean "published" |
|
20 | - t.datetime "created_at" |
|
20 | + t.datetime "created_at", :null => false |
|
21 | - t.datetime "updated_at" |
|
21 | + t.datetime "updated_at", :null => false |
|
22 | t.boolean "frontpage", :default => false |
|
22 | t.boolean "frontpage", :default => false |
|
23 | t.boolean "contest_only", :default => false |
|
23 | t.boolean "contest_only", :default => false |
|
24 | t.string "title" |
|
24 | t.string "title" |
|
25 | t.string "notes" |
|
25 | t.string "notes" |
|
26 | end |
|
26 | end |
|
27 |
|
27 | ||
|
28 | - create_table "codejom_statuses", :force => true do |t| |
|
||
|
29 | - t.integer "user_id" |
|
||
|
30 | - t.boolean "alive" |
|
||
|
31 | - t.integer "num_problems_passed" |
|
||
|
32 | - t.datetime "created_at" |
|
||
|
33 | - t.datetime "updated_at" |
|
||
|
34 | - end |
|
||
|
35 | - |
|
||
|
36 | create_table "contests", :force => true do |t| |
|
28 | create_table "contests", :force => true do |t| |
|
37 | t.string "title" |
|
29 | t.string "title" |
|
38 | t.boolean "enabled" |
|
30 | t.boolean "enabled" |
|
39 | - t.datetime "created_at" |
|
31 | + t.datetime "created_at", :null => false |
|
40 | - t.datetime "updated_at" |
|
32 | + t.datetime "updated_at", :null => false |
|
41 | t.string "name" |
|
33 | t.string "name" |
|
42 | end |
|
34 | end |
|
43 |
|
35 | ||
|
44 | create_table "contests_problems", :id => false, :force => true do |t| |
|
36 | create_table "contests_problems", :id => false, :force => true do |t| |
|
45 | t.integer "contest_id" |
|
37 | t.integer "contest_id" |
|
46 | t.integer "problem_id" |
|
38 | t.integer "problem_id" |
@@ -50,39 +42,39 | |||||
|
50 | t.integer "contest_id" |
|
42 | t.integer "contest_id" |
|
51 | t.integer "user_id" |
|
43 | t.integer "user_id" |
|
52 | end |
|
44 | end |
|
53 |
|
45 | ||
|
54 | create_table "countries", :force => true do |t| |
|
46 | create_table "countries", :force => true do |t| |
|
55 | t.string "name" |
|
47 | t.string "name" |
|
56 | - t.datetime "created_at" |
|
48 | + t.datetime "created_at", :null => false |
|
57 | - t.datetime "updated_at" |
|
49 | + t.datetime "updated_at", :null => false |
|
58 | end |
|
50 | end |
|
59 |
|
51 | ||
|
60 | create_table "descriptions", :force => true do |t| |
|
52 | create_table "descriptions", :force => true do |t| |
|
61 | t.text "body" |
|
53 | t.text "body" |
|
62 | t.boolean "markdowned" |
|
54 | t.boolean "markdowned" |
|
63 | - t.datetime "created_at" |
|
55 | + t.datetime "created_at", :null => false |
|
64 | - t.datetime "updated_at" |
|
56 | + t.datetime "updated_at", :null => false |
|
65 | end |
|
57 | end |
|
66 |
|
58 | ||
|
67 | create_table "grader_configurations", :force => true do |t| |
|
59 | create_table "grader_configurations", :force => true do |t| |
|
68 | t.string "key" |
|
60 | t.string "key" |
|
69 | t.string "value_type" |
|
61 | t.string "value_type" |
|
70 | t.string "value" |
|
62 | t.string "value" |
|
71 | - t.datetime "created_at" |
|
63 | + t.datetime "created_at", :null => false |
|
72 | - t.datetime "updated_at" |
|
64 | + t.datetime "updated_at", :null => false |
|
73 | t.text "description" |
|
65 | t.text "description" |
|
74 | end |
|
66 | end |
|
75 |
|
67 | ||
|
76 | create_table "grader_processes", :force => true do |t| |
|
68 | create_table "grader_processes", :force => true do |t| |
|
77 | t.string "host", :limit => 20 |
|
69 | t.string "host", :limit => 20 |
|
78 | t.integer "pid" |
|
70 | t.integer "pid" |
|
79 | t.string "mode" |
|
71 | t.string "mode" |
|
80 | t.boolean "active" |
|
72 | t.boolean "active" |
|
81 | - t.datetime "created_at" |
|
73 | + t.datetime "created_at", :null => false |
|
82 | - t.datetime "updated_at" |
|
74 | + t.datetime "updated_at", :null => false |
|
83 | t.integer "task_id" |
|
75 | t.integer "task_id" |
|
84 | t.string "task_type" |
|
76 | t.string "task_type" |
|
85 | t.boolean "terminated" |
|
77 | t.boolean "terminated" |
|
86 | end |
|
78 | end |
|
87 |
|
79 | ||
|
88 | add_index "grader_processes", ["host", "pid"], :name => "index_grader_processes_on_ip_and_pid" |
|
80 | add_index "grader_processes", ["host", "pid"], :name => "index_grader_processes_on_ip_and_pid" |
@@ -91,35 +83,40 | |||||
|
91 | t.string "name", :limit => 10 |
|
83 | t.string "name", :limit => 10 |
|
92 | t.string "pretty_name" |
|
84 | t.string "pretty_name" |
|
93 | t.string "ext", :limit => 10 |
|
85 | t.string "ext", :limit => 10 |
|
94 | t.string "common_ext" |
|
86 | t.string "common_ext" |
|
95 | end |
|
87 | end |
|
96 |
|
88 | ||
|
|
89 | + create_table "logins", :force => true do |t| | ||
|
|
90 | + t.string "user_id" | ||
|
|
91 | + t.string "ip_address" | ||
|
|
92 | + t.datetime "created_at", :null => false | ||
|
|
93 | + t.datetime "updated_at", :null => false | ||
|
|
94 | + end | ||
|
|
95 | + | ||
|
97 | create_table "messages", :force => true do |t| |
|
96 | create_table "messages", :force => true do |t| |
|
98 | t.integer "sender_id" |
|
97 | t.integer "sender_id" |
|
99 | t.integer "receiver_id" |
|
98 | t.integer "receiver_id" |
|
100 | t.integer "replying_message_id" |
|
99 | t.integer "replying_message_id" |
|
101 | t.text "body" |
|
100 | t.text "body" |
|
102 | t.boolean "replied" |
|
101 | t.boolean "replied" |
|
103 | - t.datetime "created_at" |
|
102 | + t.datetime "created_at", :null => false |
|
104 | - t.datetime "updated_at" |
|
103 | + t.datetime "updated_at", :null => false |
|
105 | end |
|
104 | end |
|
106 |
|
105 | ||
|
107 | create_table "problems", :force => true do |t| |
|
106 | create_table "problems", :force => true do |t| |
|
108 |
- t.string |
|
107 | + t.string "name", :limit => 30 |
|
109 |
- t.string |
|
108 | + t.string "full_name" |
|
110 |
- t.integer |
|
109 | + t.integer "full_score" |
|
111 |
- t.date |
|
110 | + t.date "date_added" |
|
112 |
- t.boolean |
|
111 | + t.boolean "available" |
|
113 |
- t.string |
|
112 | + t.string "url" |
|
114 |
- t.integer |
|
113 | + t.integer "description_id" |
|
115 |
- t.boolean |
|
114 | + t.boolean "test_allowed" |
|
116 |
- t.boolean |
|
115 | + t.boolean "output_only" |
|
117 | - t.integer "level", :default => 0 |
|
116 | + t.string "description_filename" |
|
118 | - t.datetime "updated_at" |
|
||
|
119 | - t.string "description_filename" |
|
||
|
120 | end |
|
117 | end |
|
121 |
|
118 | ||
|
122 | create_table "rights", :force => true do |t| |
|
119 | create_table "rights", :force => true do |t| |
|
123 | t.string "name" |
|
120 | t.string "name" |
|
124 | t.string "controller" |
|
121 | t.string "controller" |
|
125 | t.string "action" |
|
122 | t.string "action" |
@@ -153,27 +150,18 | |||||
|
153 | add_index "sessions", ["updated_at"], :name => "index_sessions_on_updated_at" |
|
150 | add_index "sessions", ["updated_at"], :name => "index_sessions_on_updated_at" |
|
154 |
|
151 | ||
|
155 | create_table "sites", :force => true do |t| |
|
152 | create_table "sites", :force => true do |t| |
|
156 | t.string "name" |
|
153 | t.string "name" |
|
157 | t.boolean "started" |
|
154 | t.boolean "started" |
|
158 | t.datetime "start_time" |
|
155 | t.datetime "start_time" |
|
159 | - t.datetime "created_at" |
|
156 | + t.datetime "created_at", :null => false |
|
160 | - t.datetime "updated_at" |
|
157 | + t.datetime "updated_at", :null => false |
|
161 | t.integer "country_id" |
|
158 | t.integer "country_id" |
|
162 | t.string "password" |
|
159 | t.string "password" |
|
163 | end |
|
160 | end |
|
164 |
|
161 | ||
|
165 | - create_table "submission_statuses", :force => true do |t| |
|
||
|
166 | - t.integer "user_id" |
|
||
|
167 | - t.integer "problem_id" |
|
||
|
168 | - t.boolean "passed" |
|
||
|
169 | - t.integer "submission_count" |
|
||
|
170 | - t.datetime "created_at" |
|
||
|
171 | - t.datetime "updated_at" |
|
||
|
172 | - end |
|
||
|
173 | - |
|
||
|
174 | create_table "submissions", :force => true do |t| |
|
162 | create_table "submissions", :force => true do |t| |
|
175 | t.integer "user_id" |
|
163 | t.integer "user_id" |
|
176 | t.integer "problem_id" |
|
164 | t.integer "problem_id" |
|
177 | t.integer "language_id" |
|
165 | t.integer "language_id" |
|
178 | t.text "source" |
|
166 | t.text "source" |
|
179 | t.binary "binary" |
|
167 | t.binary "binary" |
@@ -194,80 +182,61 | |||||
|
194 | t.integer "submission_id" |
|
182 | t.integer "submission_id" |
|
195 | t.datetime "created_at" |
|
183 | t.datetime "created_at" |
|
196 | t.integer "status" |
|
184 | t.integer "status" |
|
197 | t.datetime "updated_at" |
|
185 | t.datetime "updated_at" |
|
198 | end |
|
186 | end |
|
199 |
|
187 | ||
|
200 | - create_table "test_pair_assignments", :force => true do |t| |
|
||
|
201 | - t.integer "user_id" |
|
||
|
202 | - t.integer "problem_id" |
|
||
|
203 | - t.integer "test_pair_id" |
|
||
|
204 | - t.integer "test_pair_number" |
|
||
|
205 | - t.integer "request_number" |
|
||
|
206 | - t.datetime "created_at" |
|
||
|
207 | - t.datetime "updated_at" |
|
||
|
208 | - t.boolean "submitted" |
|
||
|
209 | - end |
|
||
|
210 | - |
|
||
|
211 | create_table "test_pairs", :force => true do |t| |
|
188 | create_table "test_pairs", :force => true do |t| |
|
212 | t.integer "problem_id" |
|
189 | t.integer "problem_id" |
|
213 | t.text "input", :limit => 16777215 |
|
190 | t.text "input", :limit => 16777215 |
|
214 | t.text "solution", :limit => 16777215 |
|
191 | t.text "solution", :limit => 16777215 |
|
215 | - t.datetime "created_at" |
|
192 | + t.datetime "created_at", :null => false |
|
216 | - t.datetime "updated_at" |
|
193 | + t.datetime "updated_at", :null => false |
|
217 | - t.integer "number" |
|
||
|
218 | end |
|
194 | end |
|
219 |
|
195 | ||
|
220 | create_table "test_requests", :force => true do |t| |
|
196 | create_table "test_requests", :force => true do |t| |
|
221 | t.integer "user_id" |
|
197 | t.integer "user_id" |
|
222 | t.integer "problem_id" |
|
198 | t.integer "problem_id" |
|
223 | t.integer "submission_id" |
|
199 | t.integer "submission_id" |
|
224 | t.string "input_file_name" |
|
200 | t.string "input_file_name" |
|
225 | t.string "output_file_name" |
|
201 | t.string "output_file_name" |
|
226 | t.string "running_stat" |
|
202 | t.string "running_stat" |
|
227 | t.integer "status" |
|
203 | t.integer "status" |
|
228 | - t.datetime "updated_at" |
|
204 | + t.datetime "updated_at", :null => false |
|
229 | t.datetime "submitted_at" |
|
205 | t.datetime "submitted_at" |
|
230 | t.datetime "compiled_at" |
|
206 | t.datetime "compiled_at" |
|
231 | t.text "compiler_message" |
|
207 | t.text "compiler_message" |
|
232 | t.datetime "graded_at" |
|
208 | t.datetime "graded_at" |
|
233 | t.string "grader_comment" |
|
209 | t.string "grader_comment" |
|
234 | - t.datetime "created_at" |
|
210 | + t.datetime "created_at", :null => false |
|
235 | t.float "running_time" |
|
211 | t.float "running_time" |
|
236 | t.string "exit_status" |
|
212 | t.string "exit_status" |
|
237 | t.integer "memory_usage" |
|
213 | t.integer "memory_usage" |
|
238 | end |
|
214 | end |
|
239 |
|
215 | ||
|
240 | add_index "test_requests", ["user_id", "problem_id"], :name => "index_test_requests_on_user_id_and_problem_id" |
|
216 | add_index "test_requests", ["user_id", "problem_id"], :name => "index_test_requests_on_user_id_and_problem_id" |
|
241 |
|
217 | ||
|
242 | create_table "user_contest_stats", :force => true do |t| |
|
218 | create_table "user_contest_stats", :force => true do |t| |
|
243 | t.integer "user_id" |
|
219 | t.integer "user_id" |
|
244 | t.datetime "started_at" |
|
220 | t.datetime "started_at" |
|
245 | - t.datetime "created_at" |
|
221 | + t.datetime "created_at", :null => false |
|
246 | - t.datetime "updated_at" |
|
222 | + t.datetime "updated_at", :null => false |
|
247 | t.boolean "forced_logout" |
|
223 | t.boolean "forced_logout" |
|
248 | end |
|
224 | end |
|
249 |
|
225 | ||
|
250 | create_table "users", :force => true do |t| |
|
226 | create_table "users", :force => true do |t| |
|
251 |
- t.string "login", |
|
227 | + t.string "login", :limit => 50 |
|
252 | t.string "full_name" |
|
228 | t.string "full_name" |
|
253 | t.string "hashed_password" |
|
229 | t.string "hashed_password" |
|
254 |
- t.string "salt", |
|
230 | + t.string "salt", :limit => 5 |
|
255 | t.string "alias" |
|
231 | t.string "alias" |
|
256 | t.string "email" |
|
232 | t.string "email" |
|
257 | t.integer "site_id" |
|
233 | t.integer "site_id" |
|
258 | t.integer "country_id" |
|
234 | t.integer "country_id" |
|
259 |
- t.boolean "activated", |
|
235 | + t.boolean "activated", :default => false |
|
260 | t.datetime "created_at" |
|
236 | t.datetime "created_at" |
|
261 | t.datetime "updated_at" |
|
237 | t.datetime "updated_at" |
|
262 | - t.string "member1_full_name" |
|
||
|
263 | - t.string "member2_full_name" |
|
||
|
264 | - t.string "member3_full_name" |
|
||
|
265 | - t.boolean "high_school" |
|
||
|
266 | - t.string "member1_school_name" |
|
||
|
267 | - t.string "member2_school_name" |
|
||
|
268 | - t.string "member3_school_name" |
|
||
|
269 | end |
|
238 | end |
|
270 |
|
239 | ||
|
271 | add_index "users", ["login"], :name => "index_users_on_login", :unique => true |
|
240 | add_index "users", ["login"], :name => "index_users_on_login", :unique => true |
|
272 |
|
241 | ||
|
273 | end |
|
242 | end |
You need to be logged in to leave comments.
Login now