Show More
Commit Description:
update models to satisfy rails 4
Commit Description:
update models to satisfy rails 4
File last commit:
Show/Diff file:
Action:
app/models/task.rb | 68 lines | 1.1 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
task = Task.find(:first,
:order => "created_at",
:conditions => {:status=> Task::STATUS_INQUEUE},
:lock => true)
if task!=nil
task.status = status
task.save!
end
end
rescue
task = nil
end
task
end
pramook
initial commit...
r0 end