Added more rebuild workers
authorMarcel Werk <burntime@woltlab.com>
Fri, 12 Jul 2013 12:32:26 +0000 (14:32 +0200)
committerMarcel Werk <burntime@woltlab.com>
Fri, 12 Jul 2013 12:32:26 +0000 (14:32 +0200)
com.woltlab.wcf/objectType.xml
wcfsetup/install/files/lib/acp/page/RebuildDataPage.class.php
wcfsetup/install/files/lib/system/cache/builder/EventListenerCacheBuilder.class.php
wcfsetup/install/files/lib/system/worker/AbstractWorker.class.php
wcfsetup/install/files/lib/system/worker/AttachmentRebuildDataWorker.class.php [new file with mode: 0644]
wcfsetup/install/files/lib/system/worker/LikeRebuildDataWorker.class.php [new file with mode: 0644]

index 24cea360ff8d9b488cf1f37a46735492791440d1..2b6f800839cd4ec653e60b2d4e0652780e0f5097 100644 (file)
                        <name>com.woltlab.wcf.user</name>
                        <definitionname>com.woltlab.wcf.rebuildData</definitionname>
                        <classname><![CDATA[wcf\system\worker\UserRebuildDataWorker]]></classname>
+                       <nicevalue>70</nicevalue>
+               </type>
+               <type>
+                       <name>com.woltlab.wcf.like</name>
+                       <definitionname>com.woltlab.wcf.rebuildData</definitionname>
+                       <classname><![CDATA[wcf\system\worker\LikeRebuildDataWorker]]></classname>
+               </type>
+               <type>
+                       <name>com.woltlab.wcf.attachment</name>
+                       <definitionname>com.woltlab.wcf.rebuildData</definitionname>
+                       <classname><![CDATA[wcf\system\worker\AttachmentRebuildDataWorker]]></classname>
+                       <nicevalue>100</nicevalue>
                </type>
                <!-- /rebuild data workers -->
        </import>
index 85c2060829eb678f071a9e57f968894195e5cb3f..5acaed2fc0b7269dbe5c5f36ad8cff70aa358961 100644 (file)
@@ -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;
+               });
        }
        
        /**
index f202e77d3ea9efccb9174dadbc07b1920811d37a..145f4925a9d79b9ec4156439f84f680cae8e73c2 100644 (file)
@@ -69,6 +69,6 @@ class EventListenerCacheBuilder extends AbstractCacheBuilder {
                }
                else {
                        return strcmp($listenerA['listenerClassName'], $listenerB['listenerClassName']);
-               }       
+               }
        }
 }
index a9d501c752bb6f1c2dc93679e74a828d2f6f026f..0d21bc60ae6b8ab2b260ffc3bb63599d2ba726a4 100644 (file)
@@ -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 (file)
index 0000000..5497775
--- /dev/null
@@ -0,0 +1,45 @@
+<?php
+namespace wcf\system\worker;
+use wcf\data\attachment\AttachmentAction;
+
+/**
+ * Worker implementation for updating attachments.
+ * 
+ * @author     Marcel Werk
+ * @copyright  2001-2013 WoltLab GmbH
+ * @license    GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @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 (file)
index 0000000..39770af
--- /dev/null
@@ -0,0 +1,59 @@
+<?php
+namespace wcf\system\worker;
+use wcf\system\user\activity\point\UserActivityPointHandler;
+
+/**
+ * Worker implementation for updating likes.
+ * 
+ * @author     Marcel Werk
+ * @copyright  2001-2013 WoltLab GmbH
+ * @license    GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @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);
+       }
+}