siplify grapper ask for speed
This commit is contained in:
1 parent
8ec2203918
commit
d221ff6eac
36 files changed
+111
-18439
No files matched your search
@@ -26,6 +26,7 @@ trait GrappingSofascore
|
||||
protected int $debug;
|
||||
|
||||
protected int $restart;
|
||||
protected int $speed;
|
||||
|
||||
protected int $force;
|
||||
|
||||
@@ -59,60 +60,54 @@ trait GrappingSofascore
|
||||
|
||||
$this->force = $this->options()['f'] ?? 0;
|
||||
|
||||
switch ($this->getName()) {
|
||||
case 'grp:daily':
|
||||
$grapperSelected = $this->select_grapper();
|
||||
|
||||
$this->set_base_dir($grapperSelected);
|
||||
|
||||
switch ($grapperSelected) {
|
||||
case 'daily':
|
||||
$this->daily_grapper_nobreak();
|
||||
break;
|
||||
|
||||
default:
|
||||
// code...
|
||||
case 'back':
|
||||
$this->task_id = 1;
|
||||
$this->days_back = (int) $this->select_day();
|
||||
$this->run_days_back($grapperSelected);
|
||||
break;
|
||||
|
||||
$grapperSelected = $this->select_grapper();
|
||||
case 'range':
|
||||
$this->task_id = 3;
|
||||
$this->range_grapper_nobreak();
|
||||
break;
|
||||
|
||||
$this->set_base_dir($grapperSelected);
|
||||
case 'rose':
|
||||
$this->team_rose();
|
||||
break;
|
||||
|
||||
switch ($grapperSelected) {
|
||||
case 'daily':
|
||||
$this->task_id = 1;
|
||||
$this->days_back = (int) $this->select_day();
|
||||
$this->run_daily($grapperSelected);
|
||||
break;
|
||||
case 'settings':
|
||||
$this->settings_to_local();
|
||||
break;
|
||||
|
||||
case 'range':
|
||||
$this->task_id = 3;
|
||||
$this->range_grapper_nobreak();
|
||||
break;
|
||||
case 'excel':
|
||||
$folder = $this->select_folder();
|
||||
|
||||
case 'rose':
|
||||
$this->team_rose();
|
||||
break;
|
||||
$this->import_to_excel($folder);
|
||||
break;
|
||||
|
||||
case 'settings':
|
||||
$this->settings_to_local();
|
||||
break;
|
||||
case 'mail':
|
||||
$folder = $this->select_folder();
|
||||
|
||||
case 'excel':
|
||||
$folder = $this->select_folder();
|
||||
$this->send($folder);
|
||||
break;
|
||||
|
||||
$this->import_to_excel($folder);
|
||||
break;
|
||||
case 'clear':
|
||||
$folder = $this->select_folder();
|
||||
|
||||
case 'mail':
|
||||
$folder = $this->select_folder();
|
||||
$this->clear_folder($folder);
|
||||
break;
|
||||
|
||||
$this->send($folder);
|
||||
break;
|
||||
|
||||
case 'clear':
|
||||
$folder = $this->select_folder();
|
||||
|
||||
$this->clear_folder($folder);
|
||||
break;
|
||||
|
||||
case 'delete_orphants':
|
||||
$this->delete_imported_files_orphants();
|
||||
break;
|
||||
}
|
||||
case 'delete_orphants':
|
||||
$this->delete_imported_files_orphants();
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -133,6 +128,13 @@ trait GrappingSofascore
|
||||
$this->load_tournaments_requested($folder);
|
||||
|
||||
$restart = $this->ask_restart();
|
||||
|
||||
$this->speed = $this->ask_speed();
|
||||
|
||||
if ($this->ask_settings_download()) {
|
||||
$this->settings_to_local();
|
||||
}
|
||||
|
||||
switch ($restart) {
|
||||
case 'restart':
|
||||
$this->restart = 1;
|
||||
@@ -156,7 +158,7 @@ trait GrappingSofascore
|
||||
$res = SofaScoreTaskDay::where('grapper_id', (int) $this->task_id)->where('day', $day)->first();
|
||||
|
||||
if (! $res) {
|
||||
$this->grapped_files = $this->get_tree($this->data_dir.'/'.$day);
|
||||
$this->grapped_files = $this->get_tree($this->data_dir . '/' . $day);
|
||||
|
||||
$this->grap_tournaments_for_day($day);
|
||||
|
||||
@@ -174,7 +176,7 @@ trait GrappingSofascore
|
||||
|
||||
if (! $res) {
|
||||
|
||||
$this->grapped_files = $this->get_tree($this->data_dir.'/'.$day);
|
||||
$this->grapped_files = $this->get_tree($this->data_dir . '/' . $day);
|
||||
|
||||
$this->grap_tournaments_for_day($day);
|
||||
|
||||
@@ -196,14 +198,16 @@ trait GrappingSofascore
|
||||
}
|
||||
|
||||
/**
|
||||
* Summary of run_daily
|
||||
* Summary of run_days_back
|
||||
*/
|
||||
protected function run_daily(string $grapperSelected)
|
||||
protected function run_days_back(string $grapperSelected)
|
||||
{
|
||||
$this->load_tournaments_requested($grapperSelected);
|
||||
|
||||
$this->load_days($grapperSelected);
|
||||
|
||||
$this->speed = $this->ask_speed();
|
||||
|
||||
if ($this->confirm($this->days[0], true)) {
|
||||
|
||||
foreach ($this->days as $day) {
|
||||
@@ -247,6 +251,8 @@ trait GrappingSofascore
|
||||
break;
|
||||
}
|
||||
|
||||
$this->speed = $this->ask_speed();
|
||||
|
||||
$day_done = $this->days_done();
|
||||
|
||||
$this->load_tournaments_requested($folder);
|
||||
@@ -302,7 +308,8 @@ trait GrappingSofascore
|
||||
label: 'What task should run?',
|
||||
scroll: 10,
|
||||
options: [
|
||||
'daily' => 'Select day back',
|
||||
'daily' => 'Daily run',
|
||||
'back' => 'Select day back',
|
||||
'range' => 'Range',
|
||||
'rose' => 'Rose Teams',
|
||||
'player' => 'Player',
|
||||
@@ -332,6 +339,8 @@ trait GrappingSofascore
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
protected function select_day(): string
|
||||
{
|
||||
return text(
|
||||
@@ -353,7 +362,18 @@ trait GrappingSofascore
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
protected function ask_speed(): int
|
||||
{
|
||||
return select(
|
||||
label: 'How fast you want to go?',
|
||||
default: 1,
|
||||
options: [
|
||||
1 => 'Fast (5 -10 sec)',
|
||||
2 => 'Middle (10 - 20 sec)',
|
||||
3 => 'Slow (30 - 50 sec)',
|
||||
]
|
||||
);
|
||||
}
|
||||
protected function select_what_delete(): string
|
||||
{
|
||||
return select(
|
||||
@@ -365,4 +385,16 @@ trait GrappingSofascore
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
protected function ask_settings_download(): string
|
||||
{
|
||||
return select(
|
||||
label: 'Download setting?',
|
||||
default: 0,
|
||||
options: [
|
||||
0 => 'No',
|
||||
1 => 'Yes',
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user