From 41f8dcc9c7c9b151aa0615d858869fddb1558bce Mon Sep 17 00:00:00 2001 From: Marcel Werk Date: Fri, 12 Jul 2013 14:32:26 +0200 Subject: [PATCH] Added more rebuild workers --- com.woltlab.wcf/objectType.xml | 12 ++++ .../lib/acp/page/RebuildDataPage.class.php | 15 ++++- .../EventListenerCacheBuilder.class.php | 2 +- .../system/worker/AbstractWorker.class.php | 2 +- .../AttachmentRebuildDataWorker.class.php | 45 ++++++++++++++ .../worker/LikeRebuildDataWorker.class.php | 59 +++++++++++++++++++ 6 files changed, 132 insertions(+), 3 deletions(-) create mode 100644 wcfsetup/install/files/lib/system/worker/AttachmentRebuildDataWorker.class.php create mode 100644 wcfsetup/install/files/lib/system/worker/LikeRebuildDataWorker.class.php diff --git a/com.woltlab.wcf/objectType.xml b/com.woltlab.wcf/objectType.xml index 24cea360ff..2b6f800839 100644 --- a/com.woltlab.wcf/objectType.xml +++ b/com.woltlab.wcf/objectType.xml @@ -269,6 +269,18 @@ com.woltlab.wcf.user com.woltlab.wcf.rebuildData + 70 + + + com.woltlab.wcf.like + com.woltlab.wcf.rebuildData + + + + com.woltlab.wcf.attachment + com.woltlab.wcf.rebuildData + + 100 diff --git a/wcfsetup/install/files/lib/acp/page/RebuildDataPage.class.php b/wcfsetup/install/files/lib/acp/page/RebuildDataPage.class.php index 85c2060829..5acaed2fc0 100644 --- a/wcfsetup/install/files/lib/acp/page/RebuildDataPage.class.php +++ b/wcfsetup/install/files/lib/acp/page/RebuildDataPage.class.php @@ -40,7 +40,20 @@ class RebuildDataPage extends AbstractPage { // get object types $this->objectTypes = ObjectTypeCache::getInstance()->getObjectTypes('com.woltlab.wcf.rebuildData'); - // @todo: sort object types + // sort object types + uasort($this->objectTypes, function ($a, $b) { + $niceValueA = ($a->nicevalue ?: 0); + $niceValueB = ($b->nicevalue ?: 0); + + if ($niceValueA < $niceValueB) { + return -1; + } + else if ($niceValueA > $niceValueB) { + return 1; + } + + return 0; + }); } /** diff --git a/wcfsetup/install/files/lib/system/cache/builder/EventListenerCacheBuilder.class.php b/wcfsetup/install/files/lib/system/cache/builder/EventListenerCacheBuilder.class.php index f202e77d3e..145f4925a9 100644 --- a/wcfsetup/install/files/lib/system/cache/builder/EventListenerCacheBuilder.class.php +++ b/wcfsetup/install/files/lib/system/cache/builder/EventListenerCacheBuilder.class.php @@ -69,6 +69,6 @@ class EventListenerCacheBuilder extends AbstractCacheBuilder { } else { return strcmp($listenerA['listenerClassName'], $listenerB['listenerClassName']); - } + } } } diff --git a/wcfsetup/install/files/lib/system/worker/AbstractWorker.class.php b/wcfsetup/install/files/lib/system/worker/AbstractWorker.class.php index a9d501c752..0d21bc60ae 100644 --- a/wcfsetup/install/files/lib/system/worker/AbstractWorker.class.php +++ b/wcfsetup/install/files/lib/system/worker/AbstractWorker.class.php @@ -67,7 +67,7 @@ abstract class AbstractWorker implements IWorker { $progress = (($this->limit * ($this->loopCount + 1)) / $this->count) * 100; if ($progress > 100) $progress = 100; - return floor($progress, 0); + return floor($progress); } /** diff --git a/wcfsetup/install/files/lib/system/worker/AttachmentRebuildDataWorker.class.php b/wcfsetup/install/files/lib/system/worker/AttachmentRebuildDataWorker.class.php new file mode 100644 index 0000000000..5497775aae --- /dev/null +++ b/wcfsetup/install/files/lib/system/worker/AttachmentRebuildDataWorker.class.php @@ -0,0 +1,45 @@ + + * @package com.woltlab.wcf + * @subpackage system.worker + * @category Community Framework + */ +class AttachmentRebuildDataWorker extends AbstractRebuildDataWorker { + /** + * @see wcf\system\worker\AbstractRebuildDataWorker::$objectListClassName + */ + protected $objectListClassName = 'wcf\data\attachment\AttachmentList'; + + /** + * @see wcf\system\worker\AbstractWorker::$limit + */ + protected $limit = 50; + + /** + * @see wcf\system\worker\AbstractRebuildDataWorker::initObjectList + */ + protected function initObjectList() { + parent::initObjectList(); + + $this->objectList->sqlOrderBy = 'attachment.attachmentID'; + $this->objectList->getConditionBuilder()->add('attachment.isImage = ?', array(1)); + } + + /** + * @see wcf\system\worker\IWorker::execute() + */ + public function execute() { + parent::execute(); + + $action = new AttachmentAction($this->objectList->getObjects(), 'generateThumbnails'); + $action->executeAction(); + } +} diff --git a/wcfsetup/install/files/lib/system/worker/LikeRebuildDataWorker.class.php b/wcfsetup/install/files/lib/system/worker/LikeRebuildDataWorker.class.php new file mode 100644 index 0000000000..39770af788 --- /dev/null +++ b/wcfsetup/install/files/lib/system/worker/LikeRebuildDataWorker.class.php @@ -0,0 +1,59 @@ + + * @package com.woltlab.wcf + * @subpackage system.worker + * @category Community Framework + */ +class LikeRebuildDataWorker extends AbstractRebuildDataWorker { + /** + * @see wcf\system\worker\AbstractRebuildDataWorker::$objectListClassName + */ + protected $objectListClassName = 'wcf\data\like\LikeList'; + + /** + * @see wcf\system\worker\AbstractWorker::$limit + */ + protected $limit = 1000; + + /** + * @see wcf\system\worker\AbstractRebuildDataWorker::initObjectList + */ + protected function initObjectList() { + parent::initObjectList(); + + $this->objectList->sqlOrderBy = 'like_table.likeID'; + $this->objectList->getConditionBuilder()->add('like_table.objectUserID IS NOT NULL'); + } + + /** + * @see wcf\system\worker\IWorker::execute() + */ + public function execute() { + parent::execute(); + + if (!$this->loopCount) { + // reset activity points + UserActivityPointHandler::getInstance()->reset('com.woltlab.wcf.like.activityPointEvent.receivedLikes'); + } + + $itemsToUser = array(); + foreach ($this->objectList as $like) { + if (!isset($itemsToUser[$like->objectUserID])) { + $itemsToUser[$like->objectUserID] = 0; + } + + $itemsToUser[$like->objectUserID]++; + } + + // update activity points + UserActivityPointHandler::getInstance()->fireEvents('com.woltlab.wcf.like.activityPointEvent.receivedLikes', $itemsToUser, false); + } +} -- 2.20.1