Skip to content
Extraits de code Groupes Projets
Vérifiée Valider 86d7109b rédigé par Kubat's avatar Kubat
Parcourir les fichiers

Flatten priorities with the shuffle

parent e1272536
Aucune branche associée trouvée
Aucune étiquette associée trouvée
1 requête de fusion!60Priority
......@@ -487,18 +487,18 @@ database_queue_shuffle(volatile sqlite3 *db)
{
const char *SQL =
"BEGIN TRANSACTION;"
/* Create temporary queue. */
/* Create temporary queue */
"CREATE TEMPORARY TABLE queue_tmp"
" ( position INTEGER PRIMARY KEY AUTOINCREMENT CHECK(position > 0)"
" , kara_id INTEGER"
" , priority INTEGER NOT NULL DEFAULT 1 CHECK(priority > 0 AND priority < 6)"
" );"
/* When current is NULL, that thing is also NULL, so no insertion is done. */
/* When current is NULL, that thing is also NULL, so no insertion is done */
"INSERT INTO queue_tmp (kara_id, priority)"
" SELECT kara_id, 5"
" FROM queue"
" JOIN queue_state ON queue.position = queue_state.current;"
/* Insert Max priority in order. */
/* Insert the others karas */
"INSERT INTO queue_tmp (kara_id, priority)"
" SELECT kara_id, priority"
" FROM queue"
......@@ -506,18 +506,8 @@ database_queue_shuffle(volatile sqlite3 *db)
" queue.position <> CASE"
" WHEN queue_state.current IS NOT NULL THEN queue_state.current"
" ELSE 0 END"
" AND queue.priority = 5;"
/* Insert the others karas, where the priority is < 5. */
"INSERT INTO queue_tmp (kara_id, priority)"
" SELECT kara_id, priority"
" FROM queue"
" JOIN queue_state ON"
" queue.position <> CASE"
" WHEN queue_state.current IS NOT NULL THEN queue_state.current"
" ELSE 0 END"
" AND queue.priority <> 5"
" ORDER BY RANDOM();"
/* Do the insertion in the other way. */
/* Do the insertion in the other way */
"DELETE FROM queue;"
"DELETE FROM sqlite_sequence WHERE name = 'queue';"
"INSERT INTO queue (position, kara_id, priority)"
......@@ -526,7 +516,7 @@ database_queue_shuffle(volatile sqlite3 *db)
" ORDER BY priority, position;"
"DROP TABLE queue_tmp;"
"DELETE FROM sqlite_sequence WHERE name = 'queue_tmp';"
/* Set the current to the right kara when needed. */
/* Set the current to the right kara when needed */
"UPDATE queue_state"
" SET current = CASE"
" WHEN current NOT NULL THEN 1"
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Veuillez vous inscrire ou vous pour commenter