[Sprint/InterestingIguana](feat): Offchain boost rate limiting #475
Closes #475
May need to distribute off-chain tokens for staging, using the php-cli. php cli.php rewards issue --username=nemofin --amount=10000
- Developer
Need to do some testing, and run this by somebody. Not 100% sure I've properly filtered down the transactions as the number coming out is not quite what I'd expect (though is close). Could be related to ES running under low disk constraints.
- Resolved by Ben Hayward
- Resolved by Ben Hayward
added MR::Requires Changes scoped label
added 2 commits
added 1 commit
- 21f43ead - Updated, added in reduce for counting impressions and extra test
unmarked as a Work In Progress
changed the description
resolved all discussions
resolved all discussions
added MR::Awaiting Review scoped label and automatically removed MR::Requires Changes label
mentioned in issue #591
mentioned in issue #592
approved this merge request
approved this merge request
- Developer
@eiennohi @brianhatchet did you test with tokens? I was trying to get into this with kubectl to issue some to people. (this may have to wait till monday but if you haven't already got some, send me your usernames on staging)
added Squad::Green scoped label
- Developer
- Resolved by Ben Hayward
resolved all threads
approved this merge request
- Resolved by Ben Hayward
- Resolved by Ben Hayward
- Resolved by Ben Hayward
292 292 293 if ($manager->checkExisting($boost)) { 294 return Factory::response([ 295 'status' => 'error', 296 'message' => "There's already an ongoing boost for this entity" 297 ]); 298 } 299 293 if ($manager->checkExisting($boost)) { 294 return Factory::response([ 295 'status' => 'error', 296 'message' => "There's already an ongoing boost for this entity" 297 ]); 298 } 299 300 if ($manager->boostLimitReached($boost)) { - Owner
ideally this function would be called
isBoost...
so we know it will be a boolean
- Resolved by Ben Hayward
- Resolved by Ben Hayward
- Resolved by Ben Hayward
- Resolved by Ben Hayward
- Resolved by Ben Hayward
- Last updated by Mark Harding
162 * 163 * @param Boost $type the Boost object. 164 * @return boolean true if the boost limit has been reached. 165 */ 166 public function boostLimitReached($boost) { 167 //get offchain boosts 168 $offchain = $this->getOffchainBoosts($boost); 169 170 //filter to get todays offchain transactions 171 $offlineToday = array_filter($offchain->toArray(), function($result) { 172 return $result->getCreatedTimestamp() > time() - (60 * 60 * 24); 173 }); 174 175 //reduce the impressions to count the days boosts. 176 $acc = array_reduce($offlineToday, function($acc, $_boost) { 177 $acc += $_boost->getImpressions(); - Owner
if using
+=
on the $carry ($acc) parameter, should you not also set the initial parameter to 0? Looks to be null at present. changed this line in version 8 of the diff
- Owner
not resolved
- Resolved by Ben Hayward
- Resolved by Ben Hayward
- Resolved by Ben Hayward
added MR::Requires Changes scoped label and automatically removed MR::Awaiting Review label
resolved all threads
added MR::Awaiting Review scoped label and automatically removed MR::Requires Changes label
added MR::Requires Changes scoped label and automatically removed MR::Awaiting Review label
- Owner
failing tests
292 292 293 if ($manager->checkExisting($boost)) { 294 return Factory::response([ 295 'status' => 'error', 296 'message' => "There's already an ongoing boost for this entity" 297 ]); 298 } 299 293 if ($manager->isDuplicateBoost($boost)) { 294 return Factory::response([ 295 'status' => 'error', 296 'message' => "There's already an ongoing boost for this entity" 297 ]); 298 } 299 300 if ($manager->boostLimitReached($boost)) { - Owner
Why was this resolved?
168 * True if the boost is invalid due to the offchain boost limit being reached 169 * 170 * @param Boost $type the Boost object. 171 * @return boolean true if the boost limit has been reached. 172 */ 173 public function boostLimitReached($boost) { 174 //get offchain boosts 175 $offchain = $this->getOffchainBoosts($boost); 176 177 //filter to get todays offchain transactions 178 $offlineToday = array_filter($offchain->toArray(), function($result) { 179 return $result->getCreatedTimestamp() > time() - (60 * 60 * 24); 180 }); 181 182 //reduce the impressions to count the days boosts. 183 $acc = array_reduce($offlineToday, function($carry = 0, $_boost) { - Owner
This doesn't appear to be resolved. Please read the PHP docs, an initial value must be set in array_reduce or else it will be null.