speedup egg search

This commit is contained in:
Jérémy Munsch 2022-10-21 11:20:26 +02:00
parent 96b231f7d9
commit 85d7015157
No known key found for this signature in database
GPG key ID: 18361AF3BFEC0FEC
2 changed files with 35 additions and 1 deletions

View file

@ -27,7 +27,7 @@ class EggController extends Controller
$month = $date[1];
$moba = TraceaEgg::where('ede_code', '=', $code)
->whereDate('dcr', Carbon::createFromDate(null, $month, $day)->toDate())
->where('dcr', Carbon::createFromDate(null, $month, $day)->format('Y-m-d'))
->orderBy('box_code', 'DESC')->first();
if (!$moba) {

View file

@ -0,0 +1,34 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class AddIndexesOnTracaEgg extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('tracea_eggs', function (Blueprint $table) {
$table->index(['ede_code']);
$table->index(['dcr']);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('tracea_eggs', function (Blueprint $table) {
$table->dropIndex(['ede_code']);
$table->dropIndex(['dcr']);
});
}
}