mirror of
https://github.com/pelican-dev/panel.git
synced 2025-05-20 04:04:45 +02:00
Chunk Sushi
inserts based on rows count (#1259)
This commit is contained in:
parent
862afaa0e9
commit
22a0a52f7b
@ -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);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user