202509011736
Bug 同步TextAd 會錯 ,Sqlite筆數限制 在999
This commit is contained in:
parent
59b839111f
commit
10b8a8c95c
@ -9,6 +9,9 @@ use Illuminate\Contracts\Queue\ShouldQueue;
|
|||||||
use Illuminate\Foundation\Bus\Dispatchable;
|
use Illuminate\Foundation\Bus\Dispatchable;
|
||||||
use Illuminate\Queue\InteractsWithQueue;
|
use Illuminate\Queue\InteractsWithQueue;
|
||||||
use Illuminate\Queue\SerializesModels;
|
use Illuminate\Queue\SerializesModels;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
|
||||||
class ExportSqliteTextAdJob implements ShouldQueue
|
class ExportSqliteTextAdJob implements ShouldQueue
|
||||||
{
|
{
|
||||||
|
@ -32,7 +32,7 @@ class SendSqliteFileJob implements ShouldQueue
|
|||||||
Log::error("❌ SQLite 檔案不存在: {$path}");
|
Log::error("❌ SQLite 檔案不存在: {$path}");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$user = \App\Models\User::find(2);
|
$user = \App\Models\User::find(1);
|
||||||
$token = $user->api_plain_token;
|
$token = $user->api_plain_token;
|
||||||
|
|
||||||
$branches = $this->branchId
|
$branches = $this->branchId
|
||||||
|
@ -96,7 +96,12 @@ class SqliteExportService
|
|||||||
protected function insertData(string $table, array $rows): void
|
protected function insertData(string $table, array $rows): void
|
||||||
{
|
{
|
||||||
if (empty($rows)) return;
|
if (empty($rows)) return;
|
||||||
DB::connection($this->connection)->table($table)->insert($rows);
|
$columns = count($rows[0]);
|
||||||
|
$maxBatch = intdiv(999, $columns);
|
||||||
|
|
||||||
|
foreach (array_chunk($rows, $maxBatch) as $chunk) {
|
||||||
|
DB::connection($this->connection)->table($table)->insert($chunk);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function purge(): void
|
protected function purge(): void
|
||||||
|
Loading…
x
Reference in New Issue
Block a user