-
Notifications
You must be signed in to change notification settings - Fork 0
/
ExchangeHistoryTableFeeder.php
92 lines (75 loc) · 2.11 KB
/
ExchangeHistoryTableFeeder.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
<?php
namespace App\Console\Commands;
use App\Console\AuxiliaryClasses\DataBaseFunctions;
use App\Console\AuxiliaryClasses\HttpCalls;
use App\Console\AuxiliaryClasses\ProgressControl;
use App\InteractionMethodsMOD\GetMethods;
use Carbon\Carbon;
use DB;
use GuzzleHttp\Client;
use Illuminate\Console\Command;
use Symfony\Component\Config\Definition\Exception\Exception;
/**
* Class ExchangeHistoryTableFeeder
* @package App\Console\Commands
*/
class ExchangeHistoryTableFeeder extends Command
{
/**
* @var DataBaseFunctions
*/
protected $db_functions;
/**
* @var HttpCalls
*/
protected $http_calls;
/**
* @var ProgressControl
*/
protected $progress_control;
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'history_table:feed';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Feed the table exchange_history from DB';
/**
* Create a new command instance.
* @param DataBaseFunctions $db_functions
* @param HttpCalls $http_calls
* @param ProgressControl $progress_control
*/
public function __construct(DataBaseFunctions $db_functions,HttpCalls $http_calls,ProgressControl $progress_control)
{
parent::__construct();
$this->db_functions=$db_functions;
$this->http_calls=$http_calls;
$this->progress_control=$progress_control;
}
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
$table='exchange_history';
$symbols=$this->db_functions->truncateBDValuesAndGetNew($table);
for($i=0; $i<count($symbols); $i++){
try{
$symbol=$symbols[$i]->symbol;
$data=$this->http_calls->getExchangeHistory($symbol);
$this->db_functions->storeExchangeHistory($data,$table);
$this->progress_control->progressControl($i);
}catch(Exception $e){
}
}
echo("100% Table exchange_history fed\n");
}
}