Description:
change lock syntax to be as of rails 4
Commit status:
[Not Reviewed]
References:
Comments:
0 Commit comments 0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
Add another comment

r635:58b977bcebf1 - - 1 file changed: 1 inserted, 1 deleted

@@ -3,63 +3,63
3 belongs_to :submission
3 belongs_to :submission
4
4
5 STATUS_GRADING = 0
5 STATUS_GRADING = 0
6 STATUS_INQUEUE = 1
6 STATUS_INQUEUE = 1
7 STATUS_COMPLETE = 2
7 STATUS_COMPLETE = 2
8
8
9 def status_inqueue
9 def status_inqueue
10 self.status = Task::STATUS_INQUEUE
10 self.status = Task::STATUS_INQUEUE
11 end
11 end
12
12
13 def status_inqueue!
13 def status_inqueue!
14 status_inqueue
14 status_inqueue
15 self.save
15 self.save
16 end
16 end
17
17
18 def status_grading
18 def status_grading
19 self.status = Task::STATUS_GRADING
19 self.status = Task::STATUS_GRADING
20 end
20 end
21
21
22 def status_grading!
22 def status_grading!
23 status_grading
23 status_grading
24 self.save
24 self.save
25 end
25 end
26
26
27 def status_complete
27 def status_complete
28 self.status = Task::STATUS_COMPLETE
28 self.status = Task::STATUS_COMPLETE
29 end
29 end
30
30
31 def status_complete!
31 def status_complete!
32 status_complete
32 status_complete
33 self.save
33 self.save
34 end
34 end
35
35
36 def status_str
36 def status_str
37 case self.status
37 case self.status
38 when Task::STATUS_INQUEUE
38 when Task::STATUS_INQUEUE
39 "inqueue"
39 "inqueue"
40 when Task::STATUS_GRADING
40 when Task::STATUS_GRADING
41 "grading"
41 "grading"
42 when Task::STATUS_COMPLETE
42 when Task::STATUS_COMPLETE
43 "complete"
43 "complete"
44 end
44 end
45 end
45 end
46
46
47 def self.get_inqueue_and_change_status(status)
47 def self.get_inqueue_and_change_status(status)
48 task = nil
48 task = nil
49 begin
49 begin
50 Task.transaction do
50 Task.transaction do
51 - task = Task.where(status: Task::STATUS_INQUEUE).where(lock: true).first
51 + task = Task.where(status: Task::STATUS_INQUEUE).lock(true).first
52 if task!=nil
52 if task!=nil
53 task.status = status
53 task.status = status
54 task.save!
54 task.save!
55 end
55 end
56 end
56 end
57
57
58 rescue
58 rescue
59 task = nil
59 task = nil
60
60
61 end
61 end
62 task
62 task
63 end
63 end
64
64
65 end
65 end
You need to be logged in to leave comments. Login now