-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
348 additions
and
86 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# Upgrading from 2.x to 3.0 | ||
|
||
API client release 2.0 contains few backward incompatible changes. | ||
|
||
This guide will help you upgrade your codebase. | ||
|
||
## `UserRecommendation::create()` now accepts only `$user_id` and `$scenario` | ||
`UserReccomentation::create()` accepts only two argumens: `$user_id` and `$scenario`. | ||
Both are arguments are required. Reccomendation command can be further parametrized | ||
using fluent API. | ||
|
||
#### Before | ||
```php | ||
$recommendation = UserRecommendation::create('user-id', 5, 'scenario', 1.0, 3600); | ||
``` | ||
|
||
#### After | ||
```php | ||
$recommendation = UserRecommendation::create('user-id', 'scenario') | ||
->setCount(5) | ||
->setRotationRate(1.0) | ||
->setRotationTime(3600); | ||
``` | ||
|
||
which is equivalent to | ||
|
||
```php | ||
$recommendation = UserRecommendation::create('user-id', 'scenario'); | ||
$recommendation->setCount(5); | ||
$recommendation->setRotationRate(1.0); | ||
$recommendation->setRotationTime(3600); | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
<?php declare(strict_types=1); | ||
|
||
namespace Lmc\Matej\Model\Command; | ||
|
||
use Lmc\Matej\Model\Assertion; | ||
|
||
/** | ||
* Boosting items is a way how to modify results returend by Matej by specifying | ||
* rules to increase items relevance. | ||
*/ | ||
class Boost | ||
{ | ||
/** @var string */ | ||
private $query; | ||
/** @var float */ | ||
private $multiplier; | ||
|
||
private function __construct(string $query, float $multiplier) | ||
{ | ||
$this->setQuery($query); | ||
$this->setMultiplier($multiplier); | ||
} | ||
|
||
/** | ||
* Create boost rule to prioritize items | ||
* | ||
* @return static | ||
*/ | ||
public static function create(string $query, float $multiplier): self | ||
{ | ||
return new static($query, $multiplier); | ||
} | ||
|
||
public function setQuery(string $query): void | ||
{ | ||
$this->query = $query; | ||
} | ||
|
||
public function setMultiplier(float $multiplier): void | ||
{ | ||
Assertion::greaterThan($multiplier, 0); | ||
|
||
$this->multiplier = $multiplier; | ||
} | ||
|
||
public function jsonSerialize(): array | ||
{ | ||
return [ | ||
'query' => $this->query, | ||
'multiplier' => $this->multiplier, | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.