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
171
Issues
171
List
Boards
Labels
Service Desk
Milestones
Merge Requests
41
Merge Requests
41
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
3e9e4235
Commit
3e9e4235
authored
2 hours ago
by
Marcelo Rivera
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
(feat): implemented new offsets from v2/boost/feeds
parent
635f25dc
goal/boost-campaigns-e24
1 merge request
!235
WIP: Boost Campaigns (&24)
Pipeline
#71747297
passed with stages
in 7 minutes and 20 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
5 deletions
+25
-5
campaigns.php
Controllers/api/v2/boost/fetch/campaigns.php
+25
-5
No files found.
Controllers/api/v2/boost/fetch/campaigns.php
View file @
3e9e4235
...
...
@@ -9,6 +9,7 @@ namespace Minds\Controllers\api\v2\boost\fetch;
use
Minds\Api\Exportable
;
use
Minds\Api\Factory
;
use
Minds\Common\Urn
;
use
Minds\Core
;
use
Minds\Core\Boost
;
use
Minds\Core\Boost\Campaigns\Campaign
;
use
Minds\Core\Boost\Network
;
...
...
@@ -36,23 +37,31 @@ class campaigns implements Interfaces\Api
// Parse parameters
$type
=
$pages
[
0
]
??
'newsfeed'
;
if
(
!
in_array
(
$type
,
[
'newsfeed'
,
'content'
]))
{
return
Factory
::
response
([
'status'
=>
'error'
,
'message'
=>
'Unsupported boost type'
,
]);
}
$limit
=
abs
(
intval
(
$_GET
[
'limit'
]
??
2
));
$offset
=
$_GET
[
'offset'
]
??
0
;
$rating
=
intval
(
$_GET
[
'rating'
]
??
$currentUser
->
getBoostRating
());
$platform
=
$_GET
[
'platform'
]
??
'other'
;
$quality
=
0
;
$sync
=
(
bool
)
(
$_GET
[
'sync'
]
??
true
);
if
(
$limit
===
0
)
{
return
Factory
::
response
([
'boosts'
=>
[],
]);
}
elseif
(
$
sync
&&
$
limit
>
500
)
{
}
elseif
(
$limit
>
500
)
{
$limit
=
500
;
}
elseif
(
!
$sync
&&
$limit
>
50
)
{
$limit
=
50
;
}
$cacher
=
Core\Data\cache\factory
::
build
(
'Redis'
);
$cacheKey
=
Core\Session
::
getLoggedinUser
()
->
guid
.
':boost-offset-rotator:'
.
$type
;
$offset
=
$cacher
->
get
(
$cacheKey
);
// Options specific to newly created users (<=1 hour) and iOS users
if
(
$platform
===
'ios'
)
{
...
...
@@ -95,6 +104,17 @@ class campaigns implements Interfaces\Api
$data
[]
=
$feedSyncEntity
;
}
if
(
isset
(
$data
[
2
]))
{
// Always offset to 3rd in list
$offset
+=
2
;
}
$ttl
=
1800
;
// 30 minutes
if
((
$data
/
1000
)
<
strtotime
(
'48 hours ago'
))
{
$ttl
=
300
;
// 5 minutes;
}
$cacher
->
set
(
$cacheKey
,
$offset
,
$ttl
);
}
catch
(
\Exception
$e
)
{
error_log
(
$e
);
}
...
...
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