Scratch builds are now being moved to the top of the queue and packages
will be built by when their dependency check has succeeded.
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
SELECT
jobs.*,
rank() OVER (
- ORDER BY (NOT builds.test), builds.priority DESC, jobs.created_at
+ ORDER BY
+ builds.priority DESC,
+
+ -- Put test builds at the end of the queue
+ CASE
+ WHEN builds.test THEN 1
+ ELSE 0
+ END,
+
+ -- Order by when the install check succeeded
+ jobs.installcheck_performed_at,
+
+ -- If there is anything else, order by creation time
+ jobs.created_at
) AS _rank
FROM
jobs