Open deanmand opened 4 years ago
Here are our notes from last time.
Change the queue order by finding the number in the queue column of the number that you want. Find the number of the column of the on that is directly before the one you want. Calculate the average of the two numbers. Give the job that you want to change that average.
Query for the biggest number in the queues column and add 1 to that number. Give the new job a new number of that number.
EDIT: This does not work.
BRING TO FIRST
UPDATE job_queue SET queuePos=-1 WHERE queuePos=?; UPDATE job_queue SET queuePos= queuePos +1 WHERE queuePos < ? AND queuePos != -1; UPDATE job_queue SET queuePos= 0 WHERE queuePos = -1;
BRING TO LAST
UPDATE job_queue SET queuePos=-1 WHERE queuePos=?; UPDATE job_queue SET queuePos= queuePos-1 WHERE queuePos > ? AND queuePos != -1; UPDATE job_queue SET queuePos= (SELECT MAX(queuePos) FROM job_queue)+1 WHERE queuePos = -1;
The above methods work where ? = queuePos
If the job you want to bring to first/last.
Also, make sure to add BEGIN;
at the beginning and COMMIT;
at the end to avoid conflicts.
@pro6dog said: