Show More
Commit Description:
add model solution
Commit Description:
add model solution
File last commit:
Show/Diff file:
Action:
app/models/task.rb | 65 lines | 1.0 KiB | text/x-ruby | RubyLexer |
pramook
initial commit...
r0 class Task < ActiveRecord::Base
jittat
add some lock in task...
r30
jittat
[web] updated grader monitoring...
r105 belongs_to :submission
jittat
add some lock in task...
r30 STATUS_GRADING = 0
STATUS_INQUEUE = 1
STATUS_COMPLETE = 2
def status_inqueue
self.status = Task::STATUS_INQUEUE
end
jittat
renamed ip to host in GraderProcess...
r34 def status_inqueue!
status_inqueue
self.save
end
jittat
add some lock in task...
r30 def status_grading
self.status = Task::STATUS_GRADING
end
jittat
renamed ip to host in GraderProcess...
r34 def status_grading!
status_grading
self.save
end
jittat
add some lock in task...
r30 def status_complete
self.status = Task::STATUS_COMPLETE
end
jittat
renamed ip to host in GraderProcess...
r34 def status_complete!
status_complete
self.save
end
jittat
test interface upload...
r36 def status_str
case self.status
when Task::STATUS_INQUEUE
"inqueue"
when Task::STATUS_GRADING
"grading"
when Task::STATUS_COMPLETE
"complete"
end
end
jittat
add some lock in task...
r30 def self.get_inqueue_and_change_status(status)
task = nil
begin
Task.transaction do
change lock syntax to be as of rails 4
r635 task = Task.where(status: Task::STATUS_INQUEUE).lock(true).first
jittat
add some lock in task...
r30 if task!=nil
task.status = status
task.save!
end
end
rescue
task = nil
end
task
end
pramook
initial commit...
r0 end