fix import events
This commit is contained in:
1 parent
8578ec96bb
commit
7665da190c
2 files changed
+28
-14
No files matched your search
@@ -18,8 +18,6 @@ class Tournament
|
||||
{
|
||||
public static function load()
|
||||
{
|
||||
$days = 1;
|
||||
|
||||
$debug = Nuh::$options['d'] ?? 0;
|
||||
|
||||
$force = Nuh::$options['f'] ?? 0;
|
||||
@@ -28,11 +26,9 @@ class Tournament
|
||||
|
||||
$sport = Sport::where('id', $sport_id)->first();
|
||||
|
||||
// start yesterday
|
||||
$grapping_date = Carbon::now()->subDay();
|
||||
$_days = self::days($sport);
|
||||
|
||||
$days++;
|
||||
$days_back = Carbon::now()->subDays($days);
|
||||
dd($_days);
|
||||
|
||||
while ($grapping_date >= $days_back) {
|
||||
|
||||
@@ -179,4 +175,22 @@ class Tournament
|
||||
$grapping_date->subDay();
|
||||
}
|
||||
}
|
||||
|
||||
public static function days(Sport $sport)
|
||||
{
|
||||
$d = Carbon::now()->subDay();
|
||||
Notice::note($d->format('d. m. Y'), 'b');
|
||||
|
||||
$loop = true;
|
||||
while ($loop) {
|
||||
if (!SofaScoreDay::where('day', $d)->first()) {
|
||||
// SofaScoreDay::insert(['day' => $d]);
|
||||
$d->subDay();
|
||||
} else {
|
||||
$loop = false;
|
||||
}
|
||||
Notice::note($d->format('d. m. Y'), 'g');
|
||||
}
|
||||
return SofaScoreDay::where($sport->ss_slug, 0)->get();
|
||||
}
|
||||
}
|
||||
@@ -13,7 +13,7 @@ class ImportEvents
|
||||
{
|
||||
$now = now()->format('Y-m-d H:i:s');
|
||||
|
||||
SimpleExcelReader::create(storage_path('app/public/'.$filePath))
|
||||
SimpleExcelReader::create(storage_path('app/public/' . $filePath))
|
||||
->getRows()
|
||||
->chunk(1000)
|
||||
->each(function (LazyCollection $chunk) use ($now, $importmode) {
|
||||
@@ -66,14 +66,14 @@ class ImportEvents
|
||||
['upsert' => true],
|
||||
);
|
||||
} else {
|
||||
StatistikoEvent::import(
|
||||
StatistikoEvent::insert(
|
||||
[
|
||||
'match_id', $row[0],
|
||||
'sport_id', $row[1],
|
||||
'league_id', $row[2],
|
||||
'home_id', $row[3],
|
||||
'away_id', $row[4],
|
||||
'starttime', Carbon::parse($row[5])->toIso8601String(),
|
||||
'match_id' => $row[0],
|
||||
'sport_id' => $row[1],
|
||||
'league_id' => $row[2],
|
||||
'home_id' => $row[3],
|
||||
'away_id' => $row[4],
|
||||
'starttime' => Carbon::parse($row[5])->toIso8601String(),
|
||||
'season' => $row[6],
|
||||
'gls_h' => $row[7],
|
||||
'gls_a' => $row[8],
|
||||
|
||||
Reference in new issue
Block a user