|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
/* |
|
6
|
|
|
* Copyright Humbly Arrogant Ltd 2020-2022. |
|
7
|
|
|
* |
|
8
|
|
|
* Use of this software is governed by the Business Source License included in the LICENSE file and at https://getparthenon.com/docs/next/license. |
|
9
|
|
|
* |
|
10
|
|
|
* Change Date: TBD ( 3 years after 2.0.0 release ) |
|
11
|
|
|
* |
|
12
|
|
|
* On the date above, in accordance with the Business Source License, use of this software will be governed by the open source license specified in the LICENSE file. |
|
13
|
|
|
*/ |
|
14
|
|
|
|
|
15
|
|
|
namespace Parthenon\AbTesting\Repository\Timescale; |
|
16
|
|
|
|
|
17
|
|
|
use Doctrine\DBAL\Connection; |
|
18
|
|
|
use Parthenon\AbTesting\Repository\ExperimentLogRepositoryInterface; |
|
19
|
|
|
use Ramsey\Uuid\Uuid; |
|
20
|
|
|
use Ramsey\Uuid\UuidInterface; |
|
21
|
|
|
|
|
22
|
|
|
class ExperimentLogRepository implements ExperimentLogRepositoryInterface |
|
23
|
|
|
{ |
|
24
|
|
|
private Connection $connection; |
|
25
|
|
|
|
|
26
|
|
|
public function __construct(Connection $connection) |
|
27
|
|
|
{ |
|
28
|
|
|
$this->connection = $connection; |
|
29
|
|
|
} |
|
30
|
|
|
|
|
31
|
|
|
public function saveDecision(UuidInterface $sessionId, string $experimentName, string $decisionOutput): void |
|
32
|
|
|
{ |
|
33
|
|
|
$uuid = Uuid::uuid4(); |
|
34
|
|
|
$now = new \DateTime('now'); |
|
35
|
|
|
$query = $this->connection->prepare('INSERT INTO ab_experiment_log (id, session_id, decision_string_id, decision_output, created_at) VALUES (:id, :session_id, :decision_string_id, :decision_output, :created_at)'); |
|
36
|
|
|
$query->bindValue(':id', (string) $uuid); |
|
37
|
|
|
$query->bindValue(':session_id', (string) $sessionId); |
|
38
|
|
|
$query->bindValue(':decision_string_id', (string) $experimentName); |
|
39
|
|
|
$query->bindValue(':decision_output', (string) $decisionOutput); |
|
40
|
|
|
$query->bindValue(':created_at', $now->format('Y-m-d H:i:s')); |
|
41
|
|
|
$query->execute(); |
|
|
|
|
|
|
42
|
|
|
} |
|
43
|
|
|
|
|
44
|
|
|
public function deleteAllForSession(UuidInterface $sessionId): void |
|
45
|
|
|
{ |
|
46
|
|
|
$statement = $this->connection->prepare('DELETE FROM ab_experiment_log WHERE session_id = :session_id'); |
|
47
|
|
|
$statement->bindValue(':session_id', (string) $sessionId); |
|
48
|
|
|
$statement->execute(); |
|
|
|
|
|
|
49
|
|
|
} |
|
50
|
|
|
} |
|
51
|
|
|
|
This function has been deprecated. The supplier of the function has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.