Skip to content

Commit 4edf404

Browse files
author
Alexandra Shubenko
committed
cleanup sqlite variables
1 parent 5e88a93 commit 4edf404

3 files changed

Lines changed: 204 additions & 271 deletions

File tree

server/classes/headstart/persistence/DispatchingPersistence.php

Lines changed: 7 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -2,118 +2,55 @@
22

33
namespace headstart\persistence;
44

5-
65
/**
76
* This class implements the PersistenceInterface and provides methods to interact with the database.
87
*/
98
class DispatchingPersistence implements Persistence
109
{
11-
private Persistence $oldPersistence;
1210
private Persistence $newPersistence;
13-
private int|float $shiftReadPercentage;
14-
1511

16-
public function __construct(Persistence $oldPersistence, Persistence $newPersistence, $shiftReadPercentage)
12+
public function __construct(Persistence $newPersistence)
1713
{
18-
$this->shiftReadPercentage = $shiftReadPercentage;
19-
$this->oldPersistence = $oldPersistence;
2014
$this->newPersistence = $newPersistence;
2115
}
2216

2317
public function createVisualization($vis_id, $vis_title, $input_json, $query, $dirty_query, $params_json): void
2418
{
25-
$this->oldPersistence->createVisualization($vis_id, $vis_title, $input_json, $query, $dirty_query, $params_json);
2619
$this->newPersistence->createVisualization($vis_id, $vis_title, $input_json, $query, $dirty_query, $params_json);
2720
}
2821

2922
public function getRevision($vis_id, $rev_id): array|bool
3023
{
31-
$randomFloat = getRandomFloat();
32-
33-
if (($randomFloat * 100) > ($this->shiftReadPercentage * 100)) {
34-
$result = $this->oldPersistence->getRevision($vis_id, $rev_id);
35-
} else {
36-
$result = $this->newPersistence->getRevision($vis_id, $rev_id);
37-
}
38-
39-
return $result;
24+
return $this->newPersistence->getRevision($vis_id, $rev_id);
4025
}
4126

4227
public function writeRevision($vis_id, $data): void
4328
{
44-
$this->oldPersistence->writeRevision($vis_id, $data);
4529
$this->newPersistence->writeRevision($vis_id, $data);
4630
}
4731

4832
public function existsVisualization($vis_id): array|bool
4933
{
50-
$randomFloat = getRandomFloat();
51-
52-
if ($randomFloat * 100 > $this->shiftReadPercentage * 100) {
53-
$result = $this->oldPersistence->existsVisualization($vis_id);
54-
} else {
55-
$result = $this->newPersistence->existsVisualization($vis_id);
56-
}
57-
58-
return $result;
34+
return $this->newPersistence->existsVisualization($vis_id);
5935
}
6036

6137
public function getLastVersion($vis_id, $details, $context): array|bool
6238
{
63-
$randomFloat = getRandomFloat();
64-
65-
if ($randomFloat * 100 > $this->shiftReadPercentage * 100) {
66-
$result = $this->oldPersistence->getLastVersion($vis_id, $details, $context);
67-
} else {
68-
$result = $this->newPersistence->getLastVersion($vis_id, $details, $context);
69-
}
70-
71-
return $result;
39+
return $this->newPersistence->getLastVersion($vis_id, $details, $context);
7240
}
7341

7442
public function getLatestRevisions(): array|bool
7543
{
76-
$randomFloat = getRandomFloat();
77-
78-
if ($randomFloat * 100 > $this->shiftReadPercentage * 100) {
79-
$result = $this->oldPersistence->getLatestRevisions();
80-
} else {
81-
$result = $this->newPersistence->getLatestRevisions();
82-
}
83-
84-
return $result;
44+
return $this->newPersistence->getLatestRevisions();
8545
}
8646

8747
public function getContext($vis_id): array|bool
8848
{
89-
$randomFloat = getRandomFloat();
90-
91-
if ($randomFloat * 100 > $this->shiftReadPercentage * 100) {
92-
$result = $this->oldPersistence->getContext($vis_id);
93-
} else {
94-
$result = $this->newPersistence->getContext($vis_id);
95-
}
96-
97-
return $result;
49+
return $this->newPersistence->getContext($vis_id);
9850
}
9951

10052
public function createID($string_array, $payload): string
10153
{
102-
$randomFloat = getRandomFloat();
103-
104-
if ($randomFloat * 100 > $this->shiftReadPercentage * 100) {
105-
$result = $this->oldPersistence->createID($string_array, $payload);
106-
} else {
107-
$result = $this->newPersistence->createID($string_array, $payload);
108-
}
109-
110-
return $result;
54+
return $this->newPersistence->createID($string_array, $payload);
11155
}
11256
}
113-
114-
115-
// function for random float number generation from 0 to 1
116-
function getRandomFloat(): float
117-
{
118-
return mt_rand() / mt_getrandmax();
119-
}

0 commit comments

Comments
 (0)