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
@@ -22,6 +22,9
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'
@@ -1,4 +1,8
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
@@ -11,33 +11,25
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 => 20121001033508) do
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
@@ -53,23 +45,23
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
@@ -78,8 +70,8
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"
@@ -94,14 +86,21
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|
@@ -114,8 +113,6
114 t.integer "description_id"
113 t.integer "description_id"
115 t.boolean "test_allowed"
114 t.boolean "test_allowed"
116 t.boolean "output_only"
115 t.boolean "output_only"
117 - t.integer "level", :default => 0
118 - t.datetime "updated_at"
119 t.string "description_filename"
116 t.string "description_filename"
120 end
117 end
121
118
@@ -156,21 +153,12
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"
@@ -197,24 +185,12
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|
@@ -225,13 +201,13
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"
@@ -242,8 +218,8
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
@@ -259,13 +235,6
259 t.boolean "activated", :default => false
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
You need to be logged in to leave comments. Login now