wip
This commit is contained in:
1 parent
6662b0a823
commit
750b8bc571
3 files changed
+37
-30
No files matched your search
@@ -42,11 +42,13 @@ class BoxesBettypeAll extends StatsOverviewWidget
|
||||
return [];
|
||||
}
|
||||
|
||||
// dd($this->filters);
|
||||
|
||||
// BOX TOTAL
|
||||
$count_events = $data['count_events'];
|
||||
$boxes = [];
|
||||
$boxes[] = Stat::make('Total', self::template_total($count_events))
|
||||
->description(fn () => $similar_past_matches == 'all' ? 'SPM Database' : 'SPM League')
|
||||
->description(fn () => $similar_past_matches == 'none' ? 'Team Selected' : 'Similar Past Matches')
|
||||
->extraAttributes(['x-init' => "animate('number-of-events', $count_events);", 'class' => 'box-success justify-center']);
|
||||
|
||||
// BOX 1X2
|
||||
|
||||
@@ -116,32 +116,32 @@ trait GrapSofascore
|
||||
/**
|
||||
* day 1
|
||||
*/
|
||||
$this->clear_folder($folder, 'all');
|
||||
// $this->clear_folder($folder, 'all');
|
||||
|
||||
$day = Carbon::now()->subDay()->format('Y-m-d');
|
||||
// $day = Carbon::now()->subDay()->format('Y-m-d');
|
||||
|
||||
$this->grap_tournaments_for_day($day);
|
||||
// $this->grap_tournaments_for_day($day);
|
||||
|
||||
foreach ($this->tournaments_requested as $tournament) {
|
||||
$this->get_event($day, $tournament);
|
||||
}
|
||||
// foreach ($this->tournaments_requested as $tournament) {
|
||||
// $this->get_event($day, $tournament);
|
||||
// }
|
||||
|
||||
$this->import_to_excel($folder, "Daily-$day");
|
||||
|
||||
$this->clear_folder($folder, 'data');
|
||||
// $this->import_to_excel($day, "Daily-$day");
|
||||
|
||||
/**
|
||||
* day 5
|
||||
*/
|
||||
// $this->clear_folder($folder, 'data');
|
||||
|
||||
$day = Carbon::now()->subDays(5)->format('Y-m-d');
|
||||
|
||||
$this->grap_tournaments_for_day($day);
|
||||
// $this->grap_tournaments_for_day($day);
|
||||
|
||||
foreach ($this->tournaments_requested as $tournament) {
|
||||
$this->get_event($day, $tournament);
|
||||
}
|
||||
// foreach ($this->tournaments_requested as $tournament) {
|
||||
// $this->get_event($day, $tournament);
|
||||
// }
|
||||
|
||||
$this->import_to_excel($folder, "Daily-$day");
|
||||
$this->import_to_excel($day, "Daily-$day");
|
||||
|
||||
$this->send($folder);
|
||||
}
|
||||
|
||||
@@ -9,9 +9,11 @@ use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||
|
||||
trait GrappingToExcel
|
||||
{
|
||||
public static $max = 2000;
|
||||
protected int $max = 2000;
|
||||
|
||||
public function import_to_excel(string $folder, $title = '')
|
||||
protected string $titel = '';
|
||||
|
||||
public function import_to_excel(string $folder, $day = '')
|
||||
{
|
||||
ini_set('memory_limit', -1);
|
||||
|
||||
@@ -19,35 +21,38 @@ trait GrappingToExcel
|
||||
Notice::note("import $folder to excel", 'g');
|
||||
}
|
||||
|
||||
if (! $title) {
|
||||
$titel = ucfirst($folder).'_'.Carbon::now()->format('Y-m-d');
|
||||
$this->titel = ucfirst($folder);
|
||||
if (! $day) {
|
||||
$this->titel .= '_'.Carbon::now()->format('Y-m-d');
|
||||
} else {
|
||||
$this->titel .= "_$day";
|
||||
}
|
||||
|
||||
$files = $this->get_tree("$this->data_dir/$folder");
|
||||
$files = $this->get_tree($this->data_dir);
|
||||
|
||||
$files = array_chunk($this->filter($files), self::$max);
|
||||
$files = array_chunk($this->filter($files), $this->max);
|
||||
|
||||
foreach ($files as $key => $value) {
|
||||
|
||||
$has = count($value);
|
||||
if (! $key && $has < self::$max) {
|
||||
if (! $key && $has < $this->max) {
|
||||
$count_from = 1;
|
||||
$count_to = $has;
|
||||
} elseif (! $key) {
|
||||
$count_from = 1;
|
||||
$key++;
|
||||
$count_to = $key * self::$max;
|
||||
} elseif ($has == self::$max) {
|
||||
$count_from = $key * self::$max + 1;
|
||||
$count_to = $key * $this->max;
|
||||
} elseif ($has == $this->max) {
|
||||
$count_from = $key * $this->max + 1;
|
||||
$key++;
|
||||
$count_to = $key * self::$max;
|
||||
$count_to = $key * $this->max;
|
||||
} else {
|
||||
$count_from = $key * self::$max + 1;
|
||||
$count_to = $key * self::$max + $has;
|
||||
$count_from = $key * $this->max + 1;
|
||||
$count_to = $key * $this->max + $has;
|
||||
}
|
||||
|
||||
$spreadsheet = new Spreadsheet;
|
||||
$spreadsheet->getProperties()->setTitle("$title-$count_from-$count_to");
|
||||
$spreadsheet->getProperties()->setTitle($this->titel.'-'.$count_from.'-'.$count_to);
|
||||
$activeWorksheet = $spreadsheet->getActiveSheet();
|
||||
|
||||
$column = 1;
|
||||
@@ -69,7 +74,7 @@ trait GrappingToExcel
|
||||
|
||||
$spreadsheet->setActiveSheetIndex(0);
|
||||
$writer = IOFactory::createWriter($spreadsheet, 'Xlsx');
|
||||
$writer->save("$this->data_dir/$folder/$titel-$count_from-$count_to.xlsx");
|
||||
$writer->save("$this->data_dir/$folder/$this->titel-$count_from-$count_to.xlsx");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user