47 lines
1.1 KiB
PHP
47 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace App\Console\Commands;
|
|
|
|
use Illuminate\Console\Command;
|
|
use Illuminate\Support\Facades\DB;
|
|
|
|
class TestSleepData extends Command
|
|
{
|
|
/**
|
|
* The name and signature of the console command.
|
|
*
|
|
* @var string
|
|
*/
|
|
protected $signature = 'test:sleep_data';
|
|
|
|
/**
|
|
* The console command description.
|
|
*
|
|
* @var string
|
|
*/
|
|
protected $description = 'Command description';
|
|
|
|
/**
|
|
* Execute the console command.
|
|
*
|
|
* @return int
|
|
*/
|
|
public function handle()
|
|
{
|
|
set_time_limit(0);
|
|
DB::table("band_sleeps_202405")->orderBy("id")->chunk(100, function ($sleeps) {
|
|
foreach ($sleeps as $sleep) {
|
|
$obj = DB::table("band_sleeps_202405_1")
|
|
->where('user_id', $sleep->user_id)
|
|
->where('band_id', $sleep->band_id)
|
|
->where("date", $sleep->date)->first();
|
|
if (empty($obj)) {
|
|
DB::table("band_sleeps_202405_1")->insert((array) $sleep);
|
|
}
|
|
}
|
|
|
|
});
|
|
return Command::SUCCESS;
|
|
}
|
|
}
|