Chainquery integration #49

Merged
marcdeb1 merged 44 commits from chainquery into master 2019-02-13 19:01:13 +01:00
3 changed files with 5 additions and 5 deletions
Showing only changes of commit d61d9ff015 - Show all commits

View file

@ -218,7 +218,7 @@ return [
* See vendor\cakephp\cakephp\src\Database\Driver for complete list * See vendor\cakephp\cakephp\src\Database\Driver for complete list
*/ */
'Datasources' => [ 'Datasources' => [
'default' => [ 'default' => [ // Chainquery database connection
'className' => 'Cake\Database\Connection', 'className' => 'Cake\Database\Connection',
'driver' => 'Cake\Database\Driver\Mysql', 'driver' => 'Cake\Database\Driver\Mysql',
'persistent' => false, 'persistent' => false,
@ -260,7 +260,7 @@ return [
'url' => env('DATABASE_URL', 'chainquery.lbry.io:3600'), 'url' => env('DATABASE_URL', 'chainquery.lbry.io:3600'),
], ],
'localdb' => [ 'localdb' => [ // Local db for price history
'className' => 'Cake\Database\Connection', 'className' => 'Cake\Database\Connection',
'driver' => 'Cake\Database\Driver\Mysql', 'driver' => 'Cake\Database\Driver\Mysql',
'persistent' => false, 'persistent' => false,

View file

@ -579,9 +579,9 @@ class MainController extends AppController {
// get avg prices // get avg prices
$conn_local = ConnectionManager::get('localdb'); $conn_local = ConnectionManager::get('localdb');
$stmt = $conn_local->execute("SELECT AVG(USD) AS AvgUSD, DATE_FORMAT(Created, '$sqlDateFormat') AS TimePeriod " . $stmt_price = $conn_local->execute("SELECT AVG(USD) AS AvgUSD, DATE_FORMAT(Created, '$sqlDateFormat') AS TimePeriod " .
"FROM PriceHistory WHERE DATE_FORMAT(Created, '$sqlDateFormat') >= ? GROUP BY TimePeriod ORDER BY TimePeriod ASC", [$start->format($dateFormat)]); "FROM PriceHistory WHERE DATE_FORMAT(Created, '$sqlDateFormat') >= ? GROUP BY TimePeriod ORDER BY TimePeriod ASC", [$start->format($dateFormat)]);
$avgPrices = $stmt->fetchAll(\PDO::FETCH_OBJ); $avgPrices = $stmt_price->fetchAll(\PDO::FETCH_OBJ);
foreach ($avgPrices as $price) { foreach ($avgPrices as $price) {
if (!isset($resultSet[$price->TimePeriod])) { if (!isset($resultSet[$price->TimePeriod])) {
$resultSet[$price->TimePeriod] = []; $resultSet[$price->TimePeriod] = [];

View file

@ -5,7 +5,7 @@ namespace App\Model\Entity;
use Cake\ORM\Entity; use Cake\ORM\Entity;
class PriceHistory extends Entity { class PriceHistory extends Entity {
public $useDbConfig = 'localdb';
} }
?> ?>