Description:
heartbeat response full
Commit status:
[Not Reviewed]
References:
Comments:
0 Commit comments 0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
Add another comment

r649:3cb38436f7f6 - - 6 files changed: 41 inserted, 3 deleted

@@ -0,0 +1,9
1 + class AddHeartBeatFull < ActiveRecord::Migration
2 + def up
3 + GraderConfiguration.create key: 'right.heartbeat_response_full', value_type: 'string', value:'RESTART', description:'Heart beat response text when user got full score (set this value to the empty string to disable this feature)'
4 + end
5 +
6 + def down
7 +
8 + end
9 + end
@@ -18,14 +18,29
18 18 # hb.touch
19 19 #else
20 20 # HeartBeat.creae(user_id: @user.id, ip_address: request.remote_ip)
21 21 #end
22 22 #HeartBeat.create(user_id: @user.id, ip_address: request.remote_ip, status: params[:status])
23 23
24 + res = GraderConfiguration['right.heartbeat_response']
25 + res.strip! if res
26 + full = GraderConfiguration['right.heartbeat_response_full']
27 + full.strip! if full
28 +
29 + if full and full != ''
30 + l = Login.where(ip_address: request.remote_ip).last
31 + @user = l.user
32 + if @user.solve_all_available_problems?
33 + render text: (full || 'OK')
34 + else
35 + render text: (res || 'OK')
36 + end
37 + else
24 38 render text: (GraderConfiguration['right.heartbeat_response'] || 'OK')
25 39 end
40 + end
26 41
27 42 def index
28 43 @hb = HeartBeat.where("updated_at >= ?",Time.zone.now-2.hours).includes(:user).order(:user_id).all
29 44 @num = HeartBeat.where("updated_at >= ?",Time.zone.now-5.minutes).count(:user_id,distinct: true)
30 45 end
31 46 end
@@ -276,12 +276,21
276 276 :contest => nil,
277 277 :problems => other_avaiable_problems
278 278 }
279 279 return contest_problems
280 280 end
281 281
282 + def solve_all_available_problems?
283 + available_problems.each do |p|
284 + u = self
285 + sub = Submission.find_last_by_user_and_problem(u.id,p.id)
286 + return false if !p or !sub or sub.points < p.full_score
287 + end
288 + return true
289 + end
290 +
282 291 def available_problems
283 292 if not GraderConfiguration.multicontests?
284 293 return Problem.available_problems
285 294 else
286 295 contest_problems = []
287 296 pin = {}
@@ -87,14 +87,12
87 87 get 'heartbeat/:id/edit' => 'heartbeat#edit'
88 88
89 89 #grader
90 90 get 'graders/list', to: 'graders#list', as: 'grader_list'
91 91
92 92
93 - get 'heartbeat/:id/edit' => 'heartbeat#edit'
94 -
95 93 # See how all your routes lay out with "rake routes"
96 94
97 95 # This is a legacy wild controller route that's not recommended for RESTful applications.
98 96 # Note: This route will make all actions in every controller accessible via GET requests.
99 97 match ':controller(/:action(/:id))(.:format)', via: [:get, :post]
100 98 end
@@ -8,13 +8,13
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 that you check this file into your version control system.
13 13
14 - ActiveRecord::Schema.define(version: 20170310110146) do
14 + ActiveRecord::Schema.define(version: 20170427070345) do
15 15
16 16 create_table "announcements", force: :cascade do |t|
17 17 t.string "author", limit: 255
18 18 t.text "body", limit: 65535
19 19 t.boolean "published"
20 20 t.datetime "created_at", null: false
@@ -87,12 +87,19
87 87 :value_type => 'string',
88 88 :default_value => 'OK',
89 89 :description => 'Heart beat response text'
90 90 },
91 91
92 92 {
93 + :key => 'right.heartbeat_response_full',
94 + :value_type => 'string',
95 + :default_value => 'OK',
96 + :description => 'Heart beat response text when user got full score (set this value to the empty string to disable this feature)'
97 + },
98 +
99 + {
93 100 :key => 'right.view_testcase',
94 101 :value_type => 'boolean',
95 102 :default_value => 'false',
96 103 :description => 'When true, any user can view/download test data'
97 104 },
98 105 # If Configuration['system.online_registration'] is true, the
You need to be logged in to leave comments. Login now