if ($like->getReactionType()->isPositive()) {
$userEditor = new UserEditor(UserRuntimeCache::getInstance()->getObject($likeable->getUserID()));
$userEditor->updateCounters([
- 'likesReceived' => -1
+ 'likesReceived' => -1,
+ 'positiveReactionsReceived' => -1
]);
}
- }
- }
- else {
- if ($like->likeID) {
- if ($like->getReactionType()->isPositive() && !$reactionType->isPositive()) {
+ else if ($like->getReactionType()->isNegative()) {
$userEditor = new UserEditor(UserRuntimeCache::getInstance()->getObject($likeable->getUserID()));
$userEditor->updateCounters([
- 'likesReceived' => -1
+ 'negativeReactionsReceived' => -1
]);
}
- else if (!$like->getReactionType()->isPositive() && $reactionType->isPositive()) {
+ else if ($like->getReactionType()->isNeutral()) {
$userEditor = new UserEditor(UserRuntimeCache::getInstance()->getObject($likeable->getUserID()));
$userEditor->updateCounters([
- 'likesReceived' => 1
+ 'neutralReactionsReceived' => -1
]);
}
}
- else if ($reactionType->isPositive()) {
- // update new
- $userEditor = new UserEditor(UserRuntimeCache::getInstance()->getObject($likeable->getUserID()));
- $userEditor->updateCounters([
- 'likesReceived' => 1
- ]);
+ }
+ else {
+ $counters = [
+ 'likesReceived' => 0,
+ 'positiveReactionsReceived' => 0,
+ 'negativeReactionsReceived' => 0,
+ 'neutralReactionsReceived' => 0
+ ];
+
+ if ($like->likeID) {
+ if ($like->getReactionType()->isPositive()) {
+ $counters['likesReceived']--;
+ $counters['positiveReactionsReceived']--;
+ }
+ else if ($like->getReactionType()->isNegative()) {
+ $counters['negativeReactionsReceived']--;
+ }
+ else if ($like->getReactionType()->isNeutral()) {
+ $counters['neutralReactionsReceived']--;
+ }
+ }
+
+ if ($reactionType->isPositive()) {
+ $counters['likesReceived']++;
+ $counters['positiveReactionsReceived']++;
}
+ else if ($reactionType->isNegative()) {
+ $counters['negativeReactionsReceived']++;
+ }
+ else if ($reactionType->isNeutral()) {
+ $counters['neutralReactionsReceived']++;
+ }
+
+ $userEditor = new UserEditor(UserRuntimeCache::getInstance()->getObject($likeable->getUserID()));
+ $userEditor->updateCounters($counters);
}
-
- // @TODO update new user values positiveReactionsReceived, negativeReactionsReceived, neutralReactionsReceived
}
}
disableCoverPhoto TINYINT(1) NOT NULL DEFAULT 0,
disableCoverPhotoReason TEXT,
disableCoverPhotoExpires INT(10) NOT NULL DEFAULT 0,
+ positiveReactionsReceived MEDIUMINT(7) NOT NULL DEFAULT 0,
+ negativeReactionsReceived MEDIUMINT(7) NOT NULL DEFAULT 0,
+ neutralReactionsReceived MEDIUMINT(7) NOT NULL DEFAULT 0,
KEY username (username),
KEY email (email),
KEY registrationData (registrationIpAddress, registrationDate),
KEY activityPoints (activityPoints),
KEY likesReceived (likesReceived),
+ KEY positiveReactionsReceived (positiveReactionsReceived),
+ KEY negativeReactionsReceived (negativeReactionsReceived),
+ KEY neutralReactionsReceived (neutralReactionsReceived),
KEY authData (authData),
KEY trophyPoints (trophyPoints)
);