From 29add2f078f467e14fa9dadd1bd494942ced55a6 Mon Sep 17 00:00:00 2001 From: Korina Cordero Date: Wed, 11 Mar 2020 02:42:56 +0000 Subject: [PATCH] Add the name for the logs db to .env. Add parameter for logs db to services.yaml. #330 --- .env.dist | 5 +++++ config/services.yaml | 13 +++++++------ src/Controller/UserController.php | 4 ++-- 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/.env.dist b/.env.dist index b6a80203..9f173e4b 100644 --- a/.env.dist +++ b/.env.dist @@ -18,6 +18,11 @@ LOGGING_DATABASE_URL=mysql://db_user:db_password@127.0.0.1:3306/db_logging ###< doctrine/doctrine-bundle ### GMAPS_API_KEY=insert_gmapsapikey_here +# influxdb +INFLUXDB_HOST=127.0.0.1 +INFLUXDB_PORT=8086 +INFLUXDB_DB=logging_db + # rising tide sms gateway RT_USER=rt_user RT_PASS=rt_pass diff --git a/config/services.yaml b/config/services.yaml index ba4ed655..1a72a956 100644 --- a/config/services.yaml +++ b/config/services.yaml @@ -12,6 +12,7 @@ parameters: app_access_key: 'access_keys' cvu_brand_id: "%env(CVU_BRAND_ID)%" country_code: "%env(COUNTRY_CODE)%" + log_db: "%env(INFLUXDB_DB)%" services: # default configuration for services in *this* file @@ -22,12 +23,6 @@ services: # fetching services directly from the container via $container->get() won't work. # The best practice is to be explicit about your dependencies anyway. - # influxdb - InfluxDB\Client: - arguments: ['%env(INFLUXDB_HOST)%', '%env(INFLUXDB_PORT)%'] - InfluxDB\Database: - arguments: ['%env(INFLUXDB_DB)%', "@InfluxDB\\Client"] - # makes classes in src/ available to be used as services # this creates a service per class whose id is the fully-qualified class name App\: @@ -227,6 +222,12 @@ services: #App\Service\GISManagerInterface: "@App\\Service\\GISManager\\Bing" App\Service\GISManagerInterface: "@App\\Service\\GISManager\\OpenStreet" #App\Service\GISManagerInterface: "@App\\Service\\GISManager\\Google" + + # influxdb + InfluxDB\Client: + arguments: ['%env(INFLUXDB_HOST)%', '%env(INFLUXDB_PORT)%'] + InfluxDB\Database: + arguments: ['%env(INFLUXDB_DB)%', "@InfluxDB\\Client"] App\EventListener\JobOrderActiveCacheListener: arguments: diff --git a/src/Controller/UserController.php b/src/Controller/UserController.php index e2d9085d..8bd441aa 100644 --- a/src/Controller/UserController.php +++ b/src/Controller/UserController.php @@ -503,8 +503,8 @@ class UserController extends Controller public function getLogs(Client $client, $id) { // fetch database - // TODO: find way to replace hardcoded db name - $database = $client->selectDB('logging_db'); + $log_db = $this->getParameter('log_db'); + $database = $client->selectDB($log_db); // query will return a resultset object $query_string = 'SELECT * FROM entity_log WHERE "user" = ' . $id;