]> git.mxchange.org Git - friendica.git/commitdiff
The workerqueue is now using a view as well
authorMichael <heluecht@pirati.ca>
Fri, 24 Apr 2020 18:50:36 +0000 (18:50 +0000)
committerMichael <heluecht@pirati.ca>
Fri, 24 Apr 2020 18:50:36 +0000 (18:50 +0000)
src/Core/Worker.php
static/dbview.config.php

index f41636beda2ac6e82f7a608f1e7d5145031eae11..6fb8bd40ff7d555031e7c03a5df66e14bcd8a373 100644 (file)
@@ -684,7 +684,7 @@ class Worker
                                self::$db_duration_stat += (microtime(true) - $stamp);
                                while ($entry = DBA::fetch($jobs)) {
                                        $stamp = (float)microtime(true);
-                                       $processes = DBA::p("SELECT COUNT(*) AS `running` FROM `process` INNER JOIN `workerqueue` ON `workerqueue`.`pid` = `process`.`pid` WHERE NOT `done` AND `priority` = ?", $entry["priority"]);
+                                       $processes = DBA::p("SELECT COUNT(*) AS `running` FROM `workerqueue-view` WHERE `priority` = ?", $entry["priority"]);
                                        self::$db_duration += (microtime(true) - $stamp);
                                        self::$db_duration_stat += (microtime(true) - $stamp);
                                        if ($process = DBA::fetch($processes)) {
@@ -698,7 +698,7 @@ class Worker
                        } else {
                                $waiting_processes =  self::totalEntries();
                                $stamp = (float)microtime(true);
-                               $jobs = DBA::p("SELECT COUNT(*) AS `running`, `priority` FROM `process` INNER JOIN `workerqueue` ON `workerqueue`.`pid` = `process`.`pid` AND NOT `done` GROUP BY `priority` ORDER BY `priority`");
+                               $jobs = DBA::p("SELECT COUNT(*) AS `running`, `priority` FROM `workerqueue-view` GROUP BY `priority` ORDER BY `priority`");
                                self::$db_duration += (microtime(true) - $stamp);
                                self::$db_duration_stat += (microtime(true) - $stamp);
 
@@ -839,9 +839,7 @@ class Worker
                $running = [];
                $running_total = 0;
                $stamp = (float)microtime(true);
-               $processes = DBA::p("SELECT COUNT(DISTINCT(`process`.`pid`)) AS `running`, `priority` FROM `process`
-                       INNER JOIN `workerqueue` ON `workerqueue`.`pid` = `process`.`pid`
-                       WHERE NOT `done` GROUP BY `priority`");
+               $processes = DBA::p("SELECT COUNT(DISTINCT(`pid`)) AS `running`, `priority` FROM `workerqueue-view` GROUP BY `priority`");
                self::$db_duration += (microtime(true) - $stamp);
                while ($process = DBA::fetch($processes)) {
                        $running[$process['priority']] = $process['running'];
index 7e0ce0a0f6b8fdde39ab4705f0a9a29a4aa57192..715fb30ccd6213bc60eb7ef366e0ff1a234fceec 100755 (executable)
@@ -209,5 +209,14 @@ return [
                        INNER JOIN `contact` ON `register`.`uid` = `contact`.`uid`
                        INNER JOIN `user` ON `register`.`uid` = `user`.`uid`"
        ],
+       "workerqueue-view" => [
+               "fields" => [
+                       "pid" => ["process", "pid"],
+                       "priority" => ["workerqueue", "priority"],
+               ],
+               "query" => "FROM `process`
+                       INNER JOIN `workerqueue` ON `workerqueue`.`pid` = `process`.`pid`
+                       WHERE NOT `workerqueue`.`done`"
+       ],
 ];