<name>com.woltlab.wcf.like.activityPointEvent.receivedLikes</name>
<definitionname>com.woltlab.wcf.user.activityPointEvent</definitionname>
<points>1</points>
- <classname><![CDATA[wcf\system\user\activity\point\ReceivedLikesUserActivityPointObjectProcessor]]></classname>
</type>
<!-- /activity points -->
<definition>
<name>com.woltlab.wcf.user.activityPointEvent</name>
- <interfacename><![CDATA[wcf\system\user\activity\point\IUserActivityPointObjectProcessor]]></interfacename>
</definition>
<definition>
+++ /dev/null
-<?php
-namespace wcf\system\user\activity\point;
-use wcf\data\object\type\AbstractObjectTypeProcessor;
-
-/**
- * Abstract implementation of a user activity point object processor.
- *
- * @author Matthias Schmidt
- * @copyright 2001-2013 WoltLab GmbH
- * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
- * @package com.woltlab.wcf
- * @subpackage system.user.activity.point
- * @category Community Framework
- */
-abstract class AbstractUserActivityPointObjectProcessor extends AbstractObjectTypeProcessor implements IUserActivityPointObjectProcessor {
- /**
- * number of objects processed during one request
- * @var integer
- */
- public $limit = 500;
-}
+++ /dev/null
-<?php
-namespace wcf\system\user\activity\point;
-
-/**
- * Default implementation of a user activity point object processor.
- *
- * @author Tim Duesterhus
- * @copyright 2001-2013 WoltLab GmbH
- * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
- * @package com.woltlab.wcf
- * @subpackage system.user.activity.point
- * @category Community Framework
- */
-class DefaultUserActivityPointObjectProcessor extends AbstractUserActivityPointObjectProcessor {
- /**
- * @see wcf\system\user\activity\point\IUserActivityPointObject::countRequests();
- */
- public function countRequests() {
- return 0;
- }
-
- /**
- * @see wcf\system\user\activity\point\IUserActivityPointObject::updateActivityPointEvents();
- */
- public function updateActivityPointEvents($request) {
- return;
- }
-}
+++ /dev/null
-<?php
-namespace wcf\system\user\activity\point;
-use wcf\data\IDatabaseObjectProcessor;
-
-/**
- * Every UserActivityPointObjectProcessor has to implement this interface.
- *
- * @author Tim Duesterhus
- * @copyright 2001-2013 WoltLab GmbH
- * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
- * @package com.woltlab.wcf
- * @subpackage system.user.activity.point
- * @category Community Framework
- */
-interface IUserActivityPointObjectProcessor extends IDatabaseObjectProcessor {
- /**
- * This method has to return the amount of requests needed to completely
- * process this UserActivityPointObject.
- *
- * @return integer
- */
- public function countRequests();
-
- /**
- * This method updates the activityPointEvents. $request will be an integer
- * between 0 (first request) and the number returned by countRequests() minus 1.
- *
- * @param integer $request
- */
- public function updateActivityPointEvents($request);
-}
+++ /dev/null
-<?php
-namespace wcf\system\user\activity\point;
-use wcf\data\like\Like;
-use wcf\data\object\type\ObjectType;
-use wcf\system\database\util\PreparedStatementConditionBuilder;
-use wcf\system\WCF;
-
-/**
- * Updates events for received likes.
- *
- * @author Tim Duesterhus
- * @copyright 2001-2013 WoltLab GmbH
- * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
- * @package com.woltlab.wcf
- * @subpackage system.user.activity.point
- * @category Community Framework
- */
-class ReceivedLikesUserActivityPointObjectProcessor extends AbstractUserActivityPointObjectProcessor {
- /**
- * @see wcf\system\user\activity\point\IUserActivityPointObjectProcessor::countRequests();
- */
- public function countRequests() {
- $sql = "SELECT COUNT(*)
- FROM wcf".WCF_N."_like
- WHERE likeValue = ?";
- $statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array(Like::LIKE));
-
- return ceil($statement->fetchColumn() / $this->limit) + 1;
- }
-
- /**
- * @see wcf\system\user\activity\point\IUserActivityPointObjectProcessor::updateActivityPointEvents();
- */
- public function updateActivityPointEvents($request) {
- if ($request == 0) {
- // first request
- $sql = "DELETE FROM wcf".WCF_N."_user_activity_point_event
- WHERE objectTypeID = ?";
- $statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array($this->objectTypeID));
- }
- else {
- $sql = "SELECT likeID
- FROM wcf".WCF_N."_like
- WHERE likeValue = ?
- ORDER BY likeID ASC";
- $statement = WCF::getDB()->prepareStatement($sql, $this->limit, ($this->limit * ($request - 1)));
- $statement->execute(array(Like::LIKE));
- $likeIDs = array();
- while ($row = $statement->fetchArray()) {
- $likeIDs[] = $row['likeID'];
- }
-
- if (empty($likeIDs)) return;
-
- $conditionBuilder = new PreparedStatementConditionBuilder();
- $conditionBuilder->add("objectTypeID = ?", array($this->objectTypeID));
- $conditionBuilder->add("objectID IN (?)", array($likeIDs));
-
- // avoid problems with duplicate keys, as likes may be created in the meantime
- $sql = "DELETE FROM wcf".WCF_N."_user_activity_point_event
- ".$conditionBuilder;
- $statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute($conditionBuilder->getParameters());
-
- $conditionBuilder = new PreparedStatementConditionBuilder();
- $conditionBuilder->add("likeID IN (?)", array($likeIDs));
-
- // use INSERT ... SELECT as this makes bulk updating easier
- $sql = "INSERT INTO wcf".WCF_N."_user_activity_point_event
- (userID, objectTypeID, objectID, additionalData)
- SELECT objectUserID AS userID,
- ?,
- likeID AS objectID,
- ?
- FROM wcf".WCF_N."_like
- ".$conditionBuilder;
- $statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array_merge(array(
- $this->objectTypeID,
- serialize(array())
- ), $conditionBuilder->getParameters()));
- }
- }
-}
/**
* Worker implementation for updating user activity point events.
*
- * @author Tim Duesterhus
+ * @author Alexander Ebert
* @copyright 2001-2013 WoltLab GmbH
* @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
* @package com.woltlab.wcf
*/
class UserActivityPointUpdateEventsWorker extends AbstractWorker {
/**
- * Limiting is dependent on the actual processors.
* @see wcf\system\worker\AbstractWorker::$limit
*/
protected $limit = 1;
*/
public $objectTypes = array();
+ /**
+ * @see wcf\system\worker\IWorker
+ */
public function __construct(array $parameters) {
parent::__construct($parameters);
* @see wcf\system\worker\IWorker::countObjects()
*/
public function countObjects() {
- $this->count = 0;
- foreach ($this->objectTypes as $objectType) {
- $objectType->requests = $objectType->getProcessor()->countRequests();
- $this->count += $objectType->requests;
- }
+ $this->count = count($this->objectTypes);
}
/**
* @see wcf\system\worker\IWorker::execute()
*/
public function execute() {
- $loopCount = $this->loopCount;
+ $i = 0;
foreach ($this->objectTypes as $objectType) {
- if ($loopCount < $objectType->requests) {
- $objectType->getProcessor()->updateActivityPointEvents($loopCount);
- return;
+ if ($i == $this->loopCount) {
+ $sql = "UPDATE wcf".WCF_N."_user_activity_point
+ SET activityPoints = items * ?
+ WHERE objectTypeID = ?";
+ $statement = WCF::getDB()->prepareStatement($sql);
+ $statement->execute(array(
+ $objectType->points,
+ $objectType->objectTypeID
+ ));
}
- $loopCount -= $objectType->requests;
+
+ $i++;
}
}