Skip to content
Next
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Switch to GitLab Next
Sign in / Register
Toggle navigation
Minds Backend - Engine
Project
Project
Details
Activity
Releases
Dependency List
Cycle Analytics
Insights
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Locked Files
Issues
204
Issues
204
List
Boards
Labels
Service Desk
Milestones
Merge Requests
27
Merge Requests
27
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
List
Container Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Minds
Minds Backend - Engine
Commits
e8c67b01
Commit
e8c67b01
authored
17 hours ago
by
Ben Hayward
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Updated to switch a function name and update reduce to have init index
parent
5358b5e3
feat/rate-limit-boost-475
1 merge request
!251
[Sprint/InterestingIguana](feat): Offchain boost rate limiting #475
Pipeline
#74562961
failed with stages
in 4 minutes and 11 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
6 deletions
+6
-6
boost.php
Controllers/api/v2/boost.php
+2
-2
Manager.php
Core/Boost/Network/Manager.php
+4
-4
No files found.
Controllers/api/v2/boost.php
View file @
e8c67b01
...
...
@@ -290,14 +290,14 @@ class boost implements Interfaces\Api
->
setType
(
lcfirst
(
$pages
[
0
]))
->
setPriority
(
false
);
if
(
$manager
->
isDuplicateBoost
(
$boost
))
{
if
(
$manager
->
checkExisting
(
$boost
))
{
return
Factory
::
response
([
'status'
=>
'error'
,
'message'
=>
"There's already an ongoing boost for this entity"
]);
}
if
(
$manager
->
boostLimitReached
(
$boost
))
{
if
(
$manager
->
isBoostLimitExceededBy
(
$boost
))
{
$maxDaily
=
Di
::
_
()
->
get
(
'Config'
)
->
get
(
'max_daily_boost_views'
)
/
1000
;
return
Factory
::
response
([
'status'
=>
'error'
,
...
...
This diff is collapsed.
Click to expand it.
Core/Boost/Network/Manager.php
View file @
e8c67b01
...
...
@@ -151,7 +151,7 @@ class Manager
* @param $boost
* @return bool
*/
public
function
isDuplicateBoost
(
$boost
)
public
function
checkExisting
(
$boost
)
{
$existingBoost
=
$this
->
getList
([
'useElastic'
=>
true
,
...
...
@@ -170,7 +170,7 @@ class Manager
* @param Boost $type the Boost object.
* @return boolean true if the boost limit has been reached.
*/
public
function
boostLimitReached
(
$boost
)
{
public
function
isBoostLimitExceededBy
(
$boost
)
{
//get offchain boosts
$offchain
=
$this
->
getOffchainBoosts
(
$boost
);
...
...
@@ -180,10 +180,10 @@ class Manager
});
//reduce the impressions to count the days boosts.
$acc
=
array_reduce
(
$offlineToday
,
function
(
$carry
=
0
,
$_boost
)
{
$acc
=
array_reduce
(
$offlineToday
,
function
(
$carry
,
$_boost
)
{
$carry
+=
$_boost
->
getImpressions
();
return
$carry
;
});
}
,
0
);
$maxDaily
=
$this
->
config
->
get
(
'max_daily_boost_views'
);
return
$acc
+
$boost
->
getImpressions
()
>
$maxDaily
;
//still allow 10k
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment