1
0
Fork 0

Changes after code review

This commit is contained in:
Michael 2022-05-05 12:23:44 +00:00
parent ab42fd88a4
commit 2433fee461
7 changed files with 6 additions and 59 deletions

View file

@ -1132,7 +1132,7 @@ CREATE TABLE IF NOT EXISTS `post-delivery` (
FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE, FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
FOREIGN KEY (`inbox-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE, FOREIGN KEY (`inbox-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Status of ActivityPub inboxes'; ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Delivery data for posts for the batch processing';
-- --
-- TABLE post-delivery-data -- TABLE post-delivery-data

View file

@ -50,7 +50,7 @@ Database Tables
| [post-category](help/database/db_post-category) | post relation to categories | | [post-category](help/database/db_post-category) | post relation to categories |
| [post-collection](help/database/db_post-collection) | Collection of posts | | [post-collection](help/database/db_post-collection) | Collection of posts |
| [post-content](help/database/db_post-content) | Content for all posts | | [post-content](help/database/db_post-content) | Content for all posts |
| [post-delivery](help/database/db_post-delivery) | Status of ActivityPub inboxes | | [post-delivery](help/database/db_post-delivery) | Delivery data for posts for the batch processing |
| [post-delivery-data](help/database/db_post-delivery-data) | Delivery data for items | | [post-delivery-data](help/database/db_post-delivery-data) | Delivery data for items |
| [post-link](help/database/db_post-link) | Post related external links | | [post-link](help/database/db_post-link) | Post related external links |
| [post-media](help/database/db_post-media) | Attached media | | [post-media](help/database/db_post-media) | Attached media |

View file

@ -1,7 +1,7 @@
Table post-delivery Table post-delivery
=========== ===========
Status of ActivityPub inboxes Delivery data for posts for the batch processing
Fields Fields
------ ------

View file

@ -672,7 +672,8 @@ function item_post(App $a) {
'attach' => $datarray['attach'], 'attach' => $datarray['attach'],
'file' => $datarray['file'], 'file' => $datarray['file'],
'edited' => DateTimeFormat::utcNow(), 'edited' => DateTimeFormat::utcNow(),
'changed' => DateTimeFormat::utcNow()]; 'changed' => DateTimeFormat::utcNow()
];
Item::update($fields, ['id' => $post_id]); Item::update($fields, ['id' => $post_id]);
Item::updateDisplayCache($datarray['uri-id']); Item::updateDisplayCache($datarray['uri-id']);

View file

@ -1,51 +0,0 @@
<?php
/**
* @copyright Copyright (C) 2010-2022, the Friendica project
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
namespace Friendica\Worker;
use Friendica\Core\Worker;
use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Util\DateTimeFormat;
/**
* Delete all done workerqueue entries
*/
class CleanWorkerQueue
{
public static function execute()
{
DBA::delete('workerqueue', ["`done` AND `executed` < ?", DateTimeFormat::utc('now - 1 hour')]);
// Optimizing this table only last seconds
if (DI::config()->get('system', 'optimize_tables')) {
// We are acquiring the two locks from the worker to avoid locking problems
if (DI::lock()->acquire(Worker::LOCK_PROCESS, 10)) {
if (DI::lock()->acquire(Worker::LOCK_WORKER, 10)) {
DBA::e("OPTIMIZE TABLE `workerqueue`");
DBA::e("OPTIMIZE TABLE `process`");
DI::lock()->release(Worker::LOCK_WORKER);
}
DI::lock()->release(Worker::LOCK_PROCESS);
}
}
}
}

View file

@ -92,9 +92,6 @@ class Cron
Worker::add(PRIORITY_LOW, 'PullDirectory'); Worker::add(PRIORITY_LOW, 'PullDirectory');
} }
// Delete all done workerqueue entries
Worker::add(PRIORITY_LOW, 'CleanWorkerQueue');
// Clear cache entries // Clear cache entries
Worker::add(PRIORITY_LOW, 'ClearCache'); Worker::add(PRIORITY_LOW, 'ClearCache');

View file

@ -1158,7 +1158,7 @@ return [
] ]
], ],
"post-delivery" => [ "post-delivery" => [
"comment" => "Status of ActivityPub inboxes", "comment" => "Delivery data for posts for the batch processing",
"fields" => [ "fields" => [
"uri-id" => ["type" => "int unsigned", "not null" => "1", "primary" => "1", "foreign" => ["item-uri" => "id"], "comment" => "Id of the item-uri table entry that contains the item uri"], "uri-id" => ["type" => "int unsigned", "not null" => "1", "primary" => "1", "foreign" => ["item-uri" => "id"], "comment" => "Id of the item-uri table entry that contains the item uri"],
"inbox-id" => ["type" => "int unsigned", "not null" => "1", "primary" => "1", "foreign" => ["item-uri" => "id"], "comment" => "Item-uri id of inbox url"], "inbox-id" => ["type" => "int unsigned", "not null" => "1", "primary" => "1", "foreign" => ["item-uri" => "id"], "comment" => "Item-uri id of inbox url"],