Skip to content

Instantly share code, notes, and snippets.

@laruence
Created December 2, 2017 11:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save laruence/fe11e3743ececb7adb4791ab030acc58 to your computer and use it in GitHub Desktop.
Save laruence/fe11e3743ececb7adb4791ab030acc58 to your computer and use it in GitHub Desktop.
<?php
class ReactionRatingService
{
public function calculateBoostPoints()
{
while ($reaction = $reactions) {
$reactionRatings = $this->validFunction();
$totalWeight = 0;
$runningScore = 0;
$queue = [];
foreach ($reactionRatings as $ratingData) {
if ($runningScore != $reaction['Score']) {
if ( ! $ratingData['BoostEarned']) {
$queue[] = $ratingData['UserID'];
}
} else {
foreach ($queue as $userId) {
$userBoostPointsRecalculate[$userId][] = $reaction['ID'];
}
}
$totalWeight += $ratingData['Weight'];
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment