+ $s = q("SELECT COUNT(*) AS `total` FROM `workerqueue` WHERE `executed` = '0000-00-00 00:00:00'");
+ $entries = $s[0]["total"];
+
+ if (Config::get("system", "worker_fastlane", false) AND ($queues > 0) AND ($entries > 0) AND ($active >= $queues)) {
+ $s = q("SELECT `priority` FROM `workerqueue` WHERE `executed` = '0000-00-00 00:00:00' ORDER BY `priority` LIMIT 1");
+ $top_priority = $s[0]["priority"];
+
+ $s = q("SELECT `id` FROM `workerqueue` WHERE `priority` <= %d AND `executed` != '0000-00-00 00:00:00' LIMIT 1",
+ intval($top_priority));
+ $high_running = dbm::is_result($s);
+
+ if (!$high_running AND ($top_priority > PRIORITY_UNDEFINED) AND ($top_priority < PRIORITY_NEGLIGIBLE)) {
+ logger("There are jobs with priority ".$top_priority." waiting but none is executed. Open a fastlane.", LOGGER_DEBUG);
+ $queues = $active + 1;
+ }
+ }
+
+ // Create a list of queue entries grouped by their priority
+ $running = array(PRIORITY_CRITICAL => 0,
+ PRIORITY_HIGH => 0,
+ PRIORITY_MEDIUM => 0,
+ PRIORITY_LOW => 0,
+ PRIORITY_NEGLIGIBLE => 0);
+
+ $r = q("SELECT COUNT(*) AS `running`, `priority` FROM `process` INNER JOIN `workerqueue` ON `workerqueue`.`pid` = `process`.`pid` GROUP BY `priority`");
+ if (dbm::is_result($r))
+ foreach ($r AS $process)
+ $running[$process["priority"]] = $process["running"];
+
+ $processlist = "";
+ $r = q("SELECT COUNT(*) AS `entries`, `priority` FROM `workerqueue` GROUP BY `priority`");
+ if (dbm::is_result($r))
+ foreach ($r as $entry) {
+ if ($processlist != "")
+ $processlist .= ", ";
+ $processlist .= $entry["priority"].":".$running[$entry["priority"]]."/".$entry["entries"];
+ }