202509011736

Bug 同步TextAd 會錯 ,Sqlite筆數限制 在999
This commit is contained in:
allen.yan 2025-09-01 17:40:28 +08:00
parent 59b839111f
commit 10b8a8c95c
3 changed files with 10 additions and 2 deletions

View File

@ -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
{ {

View File

@ -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

View File

@ -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