Commit c26a72e3 authored by Guy Thouret's avatar Guy Thouret

Capture Boost rating values as an exlicitly describing constant - #1106

1 merge request!235WIP: Boost Campaigns (&24)
Pipeline #97579057 failed with stages
in 2 minutes and 40 seconds
......@@ -41,12 +41,12 @@ class fetch implements Interfaces\Api
// options specific to newly created users (<=1 hour) and iOS users
if (time() - $user->getTimeCreated() <= 3600) {
$rating = 1; // they can only see safe content
$rating = Boost\Network\Boost::RATING_SAFE;
$quality = 75;
}
if ($platform === 'ios') {
$rating = 1; // they can only see safe content
$rating = Boost\Network\Boost::RATING_SAFE;
$quality = 90;
}
......@@ -81,7 +81,7 @@ class fetch implements Interfaces\Api
if (!$response['boosts']) {
$result = Di::_()->get('Trending\Repository')->getList([
'type' => 'images',
'rating' => isset($rating) ? (int) $rating : 1,
'rating' => isset($rating) ? (int) $rating : Boost\Network\Boost::RATING_SAFE,
'limit' => $limit,
]);
......
......@@ -71,10 +71,10 @@ class campaigns implements Interfaces\Api
// Options specific to newly created users (<=1 hour) and iOS users
if ($platform === 'ios') {
$rating = 1; // they can only see safe content
$rating = Network\Boost::RATING_SAFE;
$quality = 90;
} elseif (time() - $currentUser->getTimeCreated() <= 3600) {
$rating = 1; // they can only see safe content
$rating = Network\Boost::RATING_SAFE;
$quality = 75;
}
......
......@@ -54,13 +54,13 @@ class suggested implements Interfaces\Api
$offset = intval($_GET['offset']);
}
$rating = Core\Session::getLoggedinUser()->boost_rating ?: 1;
$rating = Core\Session::getLoggedinUser()->boost_rating ?: Core\Boost\Network\Boost::RATING_SAFE;
if (isset($_GET['rating'])) {
$rating = intval($_GET['rating']);
}
if ($type == 'user') {
$rating = 1;
$rating = Core\Boost\Network\Boost::RATING_SAFE;
}
$hashtag = null;
......
......@@ -9,8 +9,6 @@ use Minds\Core;
abstract class Feed
{
const RATING_SAFE = 1;
/** @var Resolver */
protected $resolver;
/** @var User */
......@@ -102,10 +100,10 @@ abstract class Feed
protected function makeRatingAndQualitySafe(): void
{
if ($this->platform === 'ios') {
$this->rating = self::RATING_SAFE;
$this->rating = Core\Boost\Network\Boost::RATING_SAFE;
$this->quality = 90;
} elseif (time() - $this->currentUser->getTimeCreated() <= Core\Time::ONE_HOUR) {
$this->rating = self::RATING_SAFE;
$this->rating = Core\Boost\Network\Boost::RATING_SAFE;
$this->quality = 75;
}
}
......
......@@ -67,6 +67,9 @@ class Boost
const TYPE_NEWSFEED = 'newsfeed';
const TYPE_CONTENT = 'content';
const RATING_SAFE = 1;
const RATING_OPEN = 2;
/** @var int $guid */
private $guid;
......
......@@ -28,7 +28,7 @@ class ElasticRepository
public function getList($opts = [])
{
$opts = array_merge([
'rating' => 3,
'rating' => Boost::RATING_OPEN,
'token' => 0,
'offset' => null,
'order' => null,
......
......@@ -17,7 +17,7 @@ class Iterator implements \Iterator
/** @var Manager */
protected $manager;
protected $rating = 1;
protected $rating = Boost::RATING_SAFE;
protected $quality = 0;
protected $offset = self::OFFSET_START;
protected $limit = 10;
......
Please register or to comment