Chainquery integration #49
3 changed files with 5 additions and 5 deletions
|
@ -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,
|
||||||
|
|
|
@ -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] = [];
|
||||||
|
|
|
@ -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';
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
Loading…
Reference in a new issue