Chunk Sushi inserts based on rows count (#1259)

This commit is contained in:
MartinOscar 2025-04-17 00:04:58 +02:00 committed by GitHub
parent 862afaa0e9
commit 22a0a52f7b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -33,6 +33,8 @@ class File extends Model
protected $keyType = 'string'; protected $keyType = 'string';
protected int $sushiInsertChunkSize = 100;
public const ARCHIVE_MIMES = [ public const ARCHIVE_MIMES = [
'application/vnd.rar', // .rar 'application/vnd.rar', // .rar
'application/x-rar-compressed', // .rar (2) 'application/x-rar-compressed', // .rar (2)
@ -167,7 +169,7 @@ class File extends Model
throw new Exception($contents['error']); throw new Exception($contents['error']);
} }
return array_map(function ($file) { $rows = array_map(function ($file) {
return [ return [
'name' => $file['name'], 'name' => $file['name'],
'created_at' => Carbon::parse($file['created'])->timezone('UTC'), 'created_at' => Carbon::parse($file['created'])->timezone('UTC'),
@ -181,6 +183,10 @@ class File extends Model
'mime_type' => $file['mime'], 'mime_type' => $file['mime'],
]; ];
}, $contents); }, $contents);
$this->sushiInsertChunkSize = min((int) floor(999 / count($this->getSchema())), count($rows));
return $rows;
} catch (Exception $exception) { } catch (Exception $exception) {
report($exception); report($exception);