yldbouk / dpwt

Dimensional Printing Web Terminal - Website
MIT License
2 stars 0 forks source link

Create A Queue System #54

Open deanmand opened 4 years ago

yldbouk commented 4 years ago

@pro6dog said:

Project - Drawing 14778908269654016666 This explains everything.

yldbouk commented 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.

When inserting a new job

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.

yldbouk commented 4 years ago

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;

yldbouk commented 4 years ago

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;

yldbouk commented 4 years ago

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.