Description:
add login stat
Commit status:
[Not Reviewed]
References:
Comments:
0 Commit comments 0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
Add another comment

r410:1c14a43c4f1f - - 11 files changed: 102 inserted, 61 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,2
1 + module ReportHelper
2 + 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 19 contest_stat.forced_logout = false
20 20 contest_stat.save
21 21 end
22 22 end
23 23 end
24 24
25 + #save login information
26 + Login.create(user_id: user.id, ip_address: request.remote_ip)
27 +
25 28 redirect_to :controller => 'main', :action => 'list'
26 29 else
27 30 flash[:notice] = 'Wrong password'
28 31 redirect_to :controller => 'main', :action => 'login'
29 32 end
30 33 end
@@ -1,7 +1,11
1 1 CafeGrader::Application.routes.draw do
2 + get "report/login"
3 +
4 + get "logins/list"
5 +
2 6 resources :contests
3 7
4 8 resources :announcements
5 9 resources :sites
6 10
7 11 # The priority is based upon order of creation:
@@ -8,39 +8,31
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 - ActiveRecord::Schema.define(:version => 20121001033508) do
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 - t.datetime "created_at"
21 - t.datetime "updated_at"
20 + t.datetime "created_at", :null => false
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 - 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 28 create_table "contests", :force => true do |t|
37 29 t.string "title"
38 30 t.boolean "enabled"
39 - t.datetime "created_at"
40 - t.datetime "updated_at"
31 + t.datetime "created_at", :null => false
32 + t.datetime "updated_at", :null => false
41 33 t.string "name"
42 34 end
43 35
44 36 create_table "contests_problems", :id => false, :force => true do |t|
45 37 t.integer "contest_id"
46 38 t.integer "problem_id"
@@ -50,39 +42,39
50 42 t.integer "contest_id"
51 43 t.integer "user_id"
52 44 end
53 45
54 46 create_table "countries", :force => true do |t|
55 47 t.string "name"
56 - t.datetime "created_at"
57 - t.datetime "updated_at"
48 + t.datetime "created_at", :null => false
49 + t.datetime "updated_at", :null => false
58 50 end
59 51
60 52 create_table "descriptions", :force => true do |t|
61 53 t.text "body"
62 54 t.boolean "markdowned"
63 - t.datetime "created_at"
64 - t.datetime "updated_at"
55 + t.datetime "created_at", :null => false
56 + t.datetime "updated_at", :null => false
65 57 end
66 58
67 59 create_table "grader_configurations", :force => true do |t|
68 60 t.string "key"
69 61 t.string "value_type"
70 62 t.string "value"
71 - t.datetime "created_at"
72 - t.datetime "updated_at"
63 + t.datetime "created_at", :null => false
64 + t.datetime "updated_at", :null => false
73 65 t.text "description"
74 66 end
75 67
76 68 create_table "grader_processes", :force => true do |t|
77 69 t.string "host", :limit => 20
78 70 t.integer "pid"
79 71 t.string "mode"
80 72 t.boolean "active"
81 - t.datetime "created_at"
82 - t.datetime "updated_at"
73 + t.datetime "created_at", :null => false
74 + t.datetime "updated_at", :null => false
83 75 t.integer "task_id"
84 76 t.string "task_type"
85 77 t.boolean "terminated"
86 78 end
87 79
88 80 add_index "grader_processes", ["host", "pid"], :name => "index_grader_processes_on_ip_and_pid"
@@ -91,34 +83,39
91 83 t.string "name", :limit => 10
92 84 t.string "pretty_name"
93 85 t.string "ext", :limit => 10
94 86 t.string "common_ext"
95 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 96 create_table "messages", :force => true do |t|
98 97 t.integer "sender_id"
99 98 t.integer "receiver_id"
100 99 t.integer "replying_message_id"
101 100 t.text "body"
102 101 t.boolean "replied"
103 - t.datetime "created_at"
104 - t.datetime "updated_at"
102 + t.datetime "created_at", :null => false
103 + t.datetime "updated_at", :null => false
105 104 end
106 105
107 106 create_table "problems", :force => true do |t|
108 107 t.string "name", :limit => 30
109 108 t.string "full_name"
110 109 t.integer "full_score"
111 110 t.date "date_added"
112 111 t.boolean "available"
113 112 t.string "url"
114 113 t.integer "description_id"
115 114 t.boolean "test_allowed"
116 115 t.boolean "output_only"
117 - t.integer "level", :default => 0
118 - t.datetime "updated_at"
119 116 t.string "description_filename"
120 117 end
121 118
122 119 create_table "rights", :force => true do |t|
123 120 t.string "name"
124 121 t.string "controller"
@@ -153,27 +150,18
153 150 add_index "sessions", ["updated_at"], :name => "index_sessions_on_updated_at"
154 151
155 152 create_table "sites", :force => true do |t|
156 153 t.string "name"
157 154 t.boolean "started"
158 155 t.datetime "start_time"
159 - t.datetime "created_at"
160 - t.datetime "updated_at"
156 + t.datetime "created_at", :null => false
157 + t.datetime "updated_at", :null => false
161 158 t.integer "country_id"
162 159 t.string "password"
163 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 162 create_table "submissions", :force => true do |t|
175 163 t.integer "user_id"
176 164 t.integer "problem_id"
177 165 t.integer "language_id"
178 166 t.text "source"
179 167 t.binary "binary"
@@ -194,59 +182,47
194 182 t.integer "submission_id"
195 183 t.datetime "created_at"
196 184 t.integer "status"
197 185 t.datetime "updated_at"
198 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 188 create_table "test_pairs", :force => true do |t|
212 189 t.integer "problem_id"
213 190 t.text "input", :limit => 16777215
214 191 t.text "solution", :limit => 16777215
215 - t.datetime "created_at"
216 - t.datetime "updated_at"
217 - t.integer "number"
192 + t.datetime "created_at", :null => false
193 + t.datetime "updated_at", :null => false
218 194 end
219 195
220 196 create_table "test_requests", :force => true do |t|
221 197 t.integer "user_id"
222 198 t.integer "problem_id"
223 199 t.integer "submission_id"
224 200 t.string "input_file_name"
225 201 t.string "output_file_name"
226 202 t.string "running_stat"
227 203 t.integer "status"
228 - t.datetime "updated_at"
204 + t.datetime "updated_at", :null => false
229 205 t.datetime "submitted_at"
230 206 t.datetime "compiled_at"
231 207 t.text "compiler_message"
232 208 t.datetime "graded_at"
233 209 t.string "grader_comment"
234 - t.datetime "created_at"
210 + t.datetime "created_at", :null => false
235 211 t.float "running_time"
236 212 t.string "exit_status"
237 213 t.integer "memory_usage"
238 214 end
239 215
240 216 add_index "test_requests", ["user_id", "problem_id"], :name => "index_test_requests_on_user_id_and_problem_id"
241 217
242 218 create_table "user_contest_stats", :force => true do |t|
243 219 t.integer "user_id"
244 220 t.datetime "started_at"
245 - t.datetime "created_at"
246 - t.datetime "updated_at"
221 + t.datetime "created_at", :null => false
222 + t.datetime "updated_at", :null => false
247 223 t.boolean "forced_logout"
248 224 end
249 225
250 226 create_table "users", :force => true do |t|
251 227 t.string "login", :limit => 50
252 228 t.string "full_name"
@@ -256,18 +232,11
256 232 t.string "email"
257 233 t.integer "site_id"
258 234 t.integer "country_id"
259 235 t.boolean "activated", :default => false
260 236 t.datetime "created_at"
261 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 238 end
270 239
271 240 add_index "users", ["login"], :name => "index_users_on_login", :unique => true
272 241
273 242 end
You need to be logged in to leave comments. Login now