Skip to content

Commit

Permalink
fixup! restore results configurable
Browse files Browse the repository at this point in the history
watch  configurable
  • Loading branch information
fengqi committed Nov 5, 2021
1 parent 63573b0 commit 7e5f4b9
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
1 change: 1 addition & 0 deletions config/config.default.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
'user' => getenv('XHGUI_PDO_USER') ?: null,
'pass' => getenv('XHGUI_PDO_PASS') ?: null,
'table' => getenv('XHGUI_PDO_TABLE') ?: 'results',
'tableWatch' => getenv('XHGUI_PDO_TABLE_WATCHES') ?: 'watches',
],

// Database options for MongoDB.
Expand Down
5 changes: 3 additions & 2 deletions src/Db/PdoRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,13 @@ class PdoRepository
/**
* @param PDO $pdo An open database connection
* @param string $table Table name where Xhgui profiles are stored
* @param string $tableWatch Table name where Xhgui watch functions are stored
*/
public function __construct(PDO $pdo, string $table)
public function __construct(PDO $pdo, string $table, string $tableWatch)
{
$this->pdo = $pdo;
$this->tableResults = sprintf('"%s"', $table);
$this->tableWatches = 'watches';
$this->tableWatches = sprintf('"%s"', $tableWatch);
}

public function getLatest(): array
Expand Down
6 changes: 5 additions & 1 deletion src/ServiceProvider/PdoStorageProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,11 @@ public function register(Container $app): void
};

$app[PdoRepository::class] = static function ($app) {
return new PdoRepository($app['pdo'], $app['config']['pdo']['table']);
return new PdoRepository(
$app['pdo'],
$app['config']['pdo']['table'],
$app['config']['pdo']['tableWatch']
);
};

$app['searcher.pdo'] = static function ($app) {
Expand Down

0 comments on commit 7e5f4b9

Please sign in to comment.