]> git.mxchange.org Git - friendica.git/commitdiff
Added comments / hourly workerqueue deletion
authorMichael <heluecht@pirati.ca>
Tue, 15 May 2018 17:50:29 +0000 (17:50 +0000)
committerMichael <heluecht@pirati.ca>
Tue, 15 May 2018 17:50:29 +0000 (17:50 +0000)
src/Model/Item.php
src/Worker/Cron.php

index 0606f017ed3946850a5986c56f5e76283eff74ff..210a6010976c5b40fd078705142152876f166485 100644 (file)
@@ -117,10 +117,12 @@ class Item extends BaseObject
                        'verb', 'object-type', 'object', 'target', 'contact-id'];
                $item = dba::selectFirst('item', $fields, ['id' => $item_id]);
                if (!DBM::is_result($item)) {
+                       logger('Item with ID ' . $item_id . " hadn't been found.", LOGGER_DEBUG);
                        return false;
                }
 
                if ($item['deleted']) {
+                       logger('Item with ID ' . $item_id . ' is already deleted.', LOGGER_DEBUG);
                        return false;
                }
 
@@ -129,8 +131,6 @@ class Item extends BaseObject
                        $parent = ['origin' => false];
                }
 
-               logger('delete item: ' . $item['id'], LOGGER_DEBUG);
-
                // clean up categories and tags so they don't end up as orphans
 
                $matches = false;
@@ -202,6 +202,8 @@ class Item extends BaseObject
                        Worker::add(['priority' => $priority, 'dont_fork' => true], "Notifier", "drop", intval($item['id']));
                }
 
+               logger('Item with ID ' . $item_id . " had been deleted.", LOGGER_DEBUG);
+
                return true;
        }
 
index e523f75118af8ad0c415f2db2374a33f6ccf3799..867a981748d34cdd4fef7bad1f0900f421e307c1 100644 (file)
@@ -74,6 +74,7 @@ Class Cron {
                $d1 = Config::get('system', 'last_expire_day');
                $d2 = intval(DateTimeFormat::utcNow('d'));
 
+               // Daily cron calls
                if ($d2 != intval($d1)) {
 
                        Worker::add(PRIORITY_LOW, "CronJobs", "update_contact_birthdays");
@@ -90,13 +91,22 @@ Class Cron {
 
                        Worker::add(PRIORITY_LOW, "CronJobs", "update_photo_albums");
 
-                       // Delete all done workerqueue entries
-                       dba::delete('workerqueue', ['`done` AND `executed` < UTC_TIMESTAMP() - INTERVAL 12 HOUR']);
-
                        // check upstream version?
                        Worker::add(PRIORITY_LOW, 'CheckVersion');
                }
 
+               // Hourly cron calls
+               if (Config::get('system', 'last_cron_hourly', 0) + 3600 < time()) {
+
+                       // Delete all done workerqueue entries
+                       dba::delete('workerqueue', ['`done` AND `executed` < UTC_TIMESTAMP() - INTERVAL 1 HOUR']);
+
+                       // Optimizing this table only last seconds
+                       dba::e("OPTIMIZE TABLE `workerqueue`");
+
+                       Config::set('system', 'last_cron_hourly', time());
+               }
+
                // Poll contacts
                self::pollContacts($parameter, $generation);