From: Matthias Schmidt Date: Sun, 23 Jun 2019 09:40:03 +0000 (+0200) Subject: Add rebuild data worker for activity point `items` counter X-Git-Tag: 5.2.0_Alpha_1~20 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=03d98c1c696011ec2e1e09028dd12931f4106190;p=GitHub%2FWoltLab%2FWCF.git Add rebuild data worker for activity point `items` counter Close #2949 --- diff --git a/com.woltlab.wcf/objectType.xml b/com.woltlab.wcf/objectType.xml index 3d0f0921df..d6bc997d97 100644 --- a/com.woltlab.wcf/objectType.xml +++ b/com.woltlab.wcf/objectType.xml @@ -532,6 +532,12 @@ wcf\system\worker\UserRebuildDataWorker 70 + + com.woltlab.wcf.activityPointItems + com.woltlab.wcf.rebuildData + wcf\system\worker\UserActivityPointItemsRebuildDataWorker + 75 + com.woltlab.wcf.attachment com.woltlab.wcf.rebuildData diff --git a/wcfsetup/install/files/lib/system/worker/UserActivityPointItemsRebuildDataWorker.class.php b/wcfsetup/install/files/lib/system/worker/UserActivityPointItemsRebuildDataWorker.class.php new file mode 100644 index 0000000000..21da3d370c --- /dev/null +++ b/wcfsetup/install/files/lib/system/worker/UserActivityPointItemsRebuildDataWorker.class.php @@ -0,0 +1,66 @@ + + * @package WoltLabSuite\Core\System\Worker + * @since 5.2 + * + * @method UserList getObjectList() + */ +class UserActivityPointItemsRebuildDataWorker extends AbstractRebuildDataWorker { + /** + * @inheritDoc + */ + protected $objectListClassName = UserList::class; + + /** + * @inheritDoc + */ + protected $limit = 50; + + /** + * @inheritDoc + */ + public function execute() { + parent::execute(); + + if (count($this->getObjectList()) === 0) { + return; + } + + // update activity points for positive reactions + $reactionObjectType = UserActivityPointHandler::getInstance()->getObjectTypeByName('com.woltlab.wcf.like.activityPointEvent.receivedLikes'); + + $conditionBuilder = new PreparedStatementConditionBuilder(); + $conditionBuilder->add('user_activity_point.objectTypeID = ?', [$reactionObjectType->objectTypeID]); + $conditionBuilder->add('user_activity_point.userID IN (?)', [$this->getObjectList()->getObjectIDs()]); + + $sql = "UPDATE wcf" . WCF_N . "_user_activity_point user_activity_point + LEFT JOIN wcf" . WCF_N . "_user user_table + ON (user_table.userID = user_activity_point.userID) + SET user_activity_point.items = user_table.positiveReactionsReceived, + user_activity_point.activityPoints = user_activity_point.items * ? + " . $conditionBuilder; + $statement = WCF::getDB()->prepareStatement($sql); + $statement->execute(array_merge( + [$reactionObjectType->points], + $conditionBuilder->getParameters() + )); + + // update activity points + UserActivityPointHandler::getInstance()->updateUsers($this->getObjectList()->getObjectIDs()); + } +} diff --git a/wcfsetup/install/files/lib/system/worker/UserRebuildDataWorker.class.php b/wcfsetup/install/files/lib/system/worker/UserRebuildDataWorker.class.php index 7b38c7e9a5..d319285edb 100644 --- a/wcfsetup/install/files/lib/system/worker/UserRebuildDataWorker.class.php +++ b/wcfsetup/install/files/lib/system/worker/UserRebuildDataWorker.class.php @@ -14,7 +14,6 @@ use wcf\system\database\util\PreparedStatementConditionBuilder; use wcf\system\exception\SystemException; use wcf\system\html\input\HtmlInputProcessor; use wcf\system\image\ImageHandler; -use wcf\system\user\activity\point\UserActivityPointHandler; use wcf\system\WCF; /** @@ -68,9 +67,6 @@ class UserRebuildDataWorker extends AbstractRebuildDataWorker { } if (!empty($userIDs)) { - // update activity points - UserActivityPointHandler::getInstance()->updateUsers($userIDs); - // update article counter $conditionBuilder = new PreparedStatementConditionBuilder(); $conditionBuilder->add('user_table.userID IN (?)', [$userIDs]); diff --git a/wcfsetup/install/lang/de.xml b/wcfsetup/install/lang/de.xml index 51f51e24f6..42c82e02ed 100644 --- a/wcfsetup/install/lang/de.xml +++ b/wcfsetup/install/lang/de.xml @@ -2605,6 +2605,8 @@ Kein Abschnitt darf leer sein und alle Abschnitten dürfen nur folgende Zeichen + + diff --git a/wcfsetup/install/lang/en.xml b/wcfsetup/install/lang/en.xml index 074d676f5b..a0a0281b5f 100644 --- a/wcfsetup/install/lang/en.xml +++ b/wcfsetup/install/lang/en.xml @@ -2532,7 +2532,9 @@ If you have already bought the licenses for the listed apps, th - + + +