db and query optimization compl
This commit is contained in:
1 parent
9d2a8ce628
commit
40d97327d4
24 files changed
+145
-126
No files matched your search
@@ -64,7 +64,7 @@ class Odds
|
||||
262148 TOTALS OVER TIME
|
||||
11534337 GG/NG (both teams to score)
|
||||
5242880 DOUBLE CHANCE
|
||||
7340033 TO PROGRESS (to_qualify)
|
||||
7340033 TO PROGRESS (to qualify)
|
||||
6291457 DRAW NO BET
|
||||
|
||||
Not used:
|
||||
|
||||
@@ -52,7 +52,31 @@ class EventResource extends Resource
|
||||
|
||||
public static function getEloquentQuery(): Builder
|
||||
{
|
||||
return parent::getEloquentQuery()
|
||||
->where('starttime', '>', Carbon::now());
|
||||
$query = parent::getEloquentQuery()
|
||||
->where('starttime', '>', Carbon::now())
|
||||
->with('competition_group')
|
||||
->with('country')
|
||||
->with('home')
|
||||
->with('away');
|
||||
if (in_array(1, EventsTable::$bettype_settings)) {
|
||||
$query->with('odds_3way.bookmaker');
|
||||
}
|
||||
if (in_array(2, EventsTable::$bettype_settings)) {
|
||||
$query->with('odds_dc.bookmaker');
|
||||
}
|
||||
if (in_array(3, EventsTable::$bettype_settings)) {
|
||||
$query->with('odds_dnb.bookmaker');
|
||||
}
|
||||
if (in_array(4, EventsTable::$bettype_settings)) {
|
||||
$query->with('odds_ggng.bookmaker');
|
||||
}
|
||||
if (in_array(5, EventsTable::$bettype_settings)) {
|
||||
$query->with('odds_tq.bookmaker');
|
||||
}
|
||||
if (in_array(6, EventsTable::$bettype_settings)) {
|
||||
$query->with('odds_total.bookmaker');
|
||||
}
|
||||
|
||||
return $query;
|
||||
}
|
||||
}
|
||||
@@ -2,15 +2,12 @@
|
||||
|
||||
namespace App\Filament\Tables\Columns;
|
||||
|
||||
use App\Models\Odds3way;
|
||||
use Filament\Tables\Columns\Column;
|
||||
|
||||
class Column3way extends Column
|
||||
{
|
||||
protected string $view = 'filament.tables.columns.column_3way';
|
||||
|
||||
protected $data;
|
||||
|
||||
protected ?array $max;
|
||||
|
||||
protected ?array $min;
|
||||
@@ -33,26 +30,19 @@ class Column3way extends Column
|
||||
|
||||
public function loadData($record)
|
||||
{
|
||||
$this->data = Odds3way::with('bookmaker')->where('event_id', $record->id)->get();
|
||||
$this->max['h3w'] = $record->odds_3way->max('h3w');
|
||||
$this->min['h3w'] = $record->odds_3way->min('h3w');
|
||||
|
||||
$this->max['h3w'] = $this->data->max('h3w');
|
||||
$this->min['h3w'] = $this->data->min('h3w');
|
||||
$this->max['d3w'] = $record->odds_3way->max('d3w');
|
||||
$this->min['d3w'] = $record->odds_3way->min('d3w');
|
||||
|
||||
$this->max['d3w'] = $this->data->max('d3w');
|
||||
$this->min['d3w'] = $this->data->min('d3w');
|
||||
$this->max['a3w'] = $record->odds_3way->max('a3w');
|
||||
$this->min['a3w'] = $record->odds_3way->min('a3w');
|
||||
|
||||
$this->max['a3w'] = $this->data->max('a3w');
|
||||
$this->min['a3w'] = $this->data->min('a3w');
|
||||
$this->max['margin'] = $record->odds_3way->max('margin');
|
||||
$this->min['margin'] = $record->odds_3way->min('margin');
|
||||
|
||||
$this->max['margin'] = $this->data->max('margin');
|
||||
$this->min['margin'] = $this->data->min('margin');
|
||||
|
||||
$this->has_data = count($this->data) ? true : false;
|
||||
}
|
||||
|
||||
public function getData()
|
||||
{
|
||||
return $this->data;
|
||||
$this->has_data = count($record->odds_3way) ? true : false;
|
||||
}
|
||||
|
||||
public function getMax()
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
|
||||
namespace App\Filament\Tables\Columns;
|
||||
|
||||
use App\Models\OddsDc;
|
||||
use Filament\Tables\Columns\Column;
|
||||
|
||||
class ColumnDc extends Column
|
||||
@@ -13,8 +12,6 @@ class ColumnDc extends Column
|
||||
|
||||
protected ?array $min;
|
||||
|
||||
protected $data;
|
||||
|
||||
protected ?array $bookmakers;
|
||||
|
||||
protected ?bool $has_data;
|
||||
@@ -33,26 +30,19 @@ class ColumnDc extends Column
|
||||
|
||||
public function loadData($record)
|
||||
{
|
||||
$this->data = OddsDc::with('bookmaker')->where('event_id', $record->id)->get();
|
||||
$this->max['dc1x'] = $record->odds_dc->max('dc1x');
|
||||
$this->min['dc1x'] = $record->odds_dc->min('dc1x');
|
||||
|
||||
$this->max['dc1x'] = $this->data->max('dc1x');
|
||||
$this->min['dc1x'] = $this->data->min('dc1x');
|
||||
$this->max['dc12'] = $record->odds_dc->max('dc12');
|
||||
$this->min['dc12'] = $record->odds_dc->min('dc12');
|
||||
|
||||
$this->max['dc12'] = $this->data->max('dc12');
|
||||
$this->min['dc12'] = $this->data->min('dc12');
|
||||
$this->max['dcx2'] = $record->odds_dc->max('dcx2');
|
||||
$this->min['dcx2'] = $record->odds_dc->min('dcx2');
|
||||
|
||||
$this->max['dcx2'] = $this->data->max('dcx2');
|
||||
$this->min['dcx2'] = $this->data->min('dcx2');
|
||||
$this->max['margin'] = $record->odds_dc->max('margin');
|
||||
$this->min['margin'] = $record->odds_dc->min('margin');
|
||||
|
||||
$this->max['margin'] = $this->data->max('margin');
|
||||
$this->min['margin'] = $this->data->min('margin');
|
||||
|
||||
$this->has_data = count($this->data) ? true : false;
|
||||
}
|
||||
|
||||
public function getData()
|
||||
{
|
||||
return $this->data;
|
||||
$this->has_data = count($record->odds_dc) ? true : false;
|
||||
}
|
||||
|
||||
public function getMax()
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
|
||||
namespace App\Filament\Tables\Columns;
|
||||
|
||||
use App\Models\OddsDnb;
|
||||
use Filament\Tables\Columns\Column;
|
||||
|
||||
class ColumnDnb extends Column
|
||||
@@ -13,8 +12,6 @@ class ColumnDnb extends Column
|
||||
|
||||
protected ?array $min;
|
||||
|
||||
protected $data;
|
||||
|
||||
protected ?array $bookmakers;
|
||||
|
||||
protected ?bool $has_data;
|
||||
@@ -33,23 +30,16 @@ class ColumnDnb extends Column
|
||||
|
||||
public function loadData($record)
|
||||
{
|
||||
$this->data = OddsDnb::with('bookmaker')->where('event_id', $record->id)->get();
|
||||
$this->max['dnb1'] = $record->odds_dnb->max('dnb1');
|
||||
$this->min['dnb1'] = $record->odds_dnb->min('dnb1');
|
||||
|
||||
$this->max['dnb1'] = $this->data->max('dnb1');
|
||||
$this->min['dnb1'] = $this->data->min('dnb1');
|
||||
$this->max['dnb2'] = $record->odds_dnb->max('dnb2');
|
||||
$this->min['dnb2'] = $record->odds_dnb->min('dnb2');
|
||||
|
||||
$this->max['dnb2'] = $this->data->max('dnb2');
|
||||
$this->min['dnb2'] = $this->data->min('dnb2');
|
||||
$this->max['margin'] = $record->odds_dnb->max('margin');
|
||||
$this->min['margin'] = $record->odds_dnb->min('margin');
|
||||
|
||||
$this->max['margin'] = $this->data->max('margin');
|
||||
$this->min['margin'] = $this->data->min('margin');
|
||||
|
||||
$this->has_data = count($this->data) ? true : false;
|
||||
}
|
||||
|
||||
public function getData()
|
||||
{
|
||||
return $this->data;
|
||||
$this->has_data = count($record->odds_dnb) ? true : false;
|
||||
}
|
||||
|
||||
public function getMax()
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
|
||||
namespace App\Filament\Tables\Columns;
|
||||
|
||||
use App\Models\OddsGgng;
|
||||
use Filament\Tables\Columns\Column;
|
||||
|
||||
class ColumnGgng extends Column
|
||||
@@ -13,8 +12,6 @@ class ColumnGgng extends Column
|
||||
|
||||
protected ?array $min;
|
||||
|
||||
protected $data;
|
||||
|
||||
protected ?array $bookmakers;
|
||||
|
||||
protected ?bool $has_data;
|
||||
@@ -33,23 +30,16 @@ class ColumnGgng extends Column
|
||||
|
||||
public function loadData($record)
|
||||
{
|
||||
$this->data = OddsGgng::with('bookmaker')->where('event_id', $record->id)->get();
|
||||
$this->max['gg'] = $record->odds_ggng->max('gg');
|
||||
$this->min['gg'] = $record->odds_ggng->min('gg');
|
||||
|
||||
$this->max['gg'] = $this->data->max('gg');
|
||||
$this->min['gg'] = $this->data->min('gg');
|
||||
$this->max['ng'] = $record->odds_ggng->max('ng');
|
||||
$this->min['ng'] = $record->odds_ggng->min('ng');
|
||||
|
||||
$this->max['ng'] = $this->data->max('ng');
|
||||
$this->min['ng'] = $this->data->min('ng');
|
||||
$this->max['margin'] = $record->odds_ggng->max('margin');
|
||||
$this->min['margin'] = $record->odds_ggng->min('margin');
|
||||
|
||||
$this->max['margin'] = $this->data->max('margin');
|
||||
$this->min['margin'] = $this->data->min('margin');
|
||||
|
||||
$this->has_data = count($this->data) ? true : false;
|
||||
}
|
||||
|
||||
public function getData()
|
||||
{
|
||||
return $this->data;
|
||||
$this->has_data = count($record->odds_ggng) ? true : false;
|
||||
}
|
||||
|
||||
public function getMax()
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
|
||||
namespace App\Filament\Tables\Columns;
|
||||
|
||||
use App\Models\OddsTotal;
|
||||
use Filament\Tables\Columns\Column;
|
||||
|
||||
class ColumnTotal extends Column
|
||||
@@ -13,8 +12,6 @@ class ColumnTotal extends Column
|
||||
|
||||
protected ?array $min;
|
||||
|
||||
protected $data;
|
||||
|
||||
protected ?array $bookmakers;
|
||||
|
||||
protected ?bool $has_data;
|
||||
@@ -33,23 +30,16 @@ class ColumnTotal extends Column
|
||||
|
||||
public function loadData($record)
|
||||
{
|
||||
$this->data = OddsTotal::with('bookmaker')->where('event_id', $record->id)->get();
|
||||
$this->max['over'] = $record->odds_total->max('over');
|
||||
$this->min['over'] = $record->odds_total->min('over');
|
||||
|
||||
$this->max['over'] = $this->data->max('over');
|
||||
$this->min['over'] = $this->data->min('over');
|
||||
$this->max['under'] = $record->odds_total->max('under');
|
||||
$this->min['under'] = $record->odds_total->min('under');
|
||||
|
||||
$this->max['under'] = $this->data->max('under');
|
||||
$this->min['under'] = $this->data->min('under');
|
||||
$this->max['margin'] = $record->odds_total->max('margin');
|
||||
$this->min['margin'] = $record->odds_total->min('margin');
|
||||
|
||||
$this->max['margin'] = $this->data->max('margin');
|
||||
$this->min['margin'] = $this->data->min('margin');
|
||||
|
||||
$this->has_data = count($this->data) ? true : false;
|
||||
}
|
||||
|
||||
public function getData()
|
||||
{
|
||||
return $this->data;
|
||||
$this->has_data = count($record->odds_total) ? true : false;
|
||||
}
|
||||
|
||||
public function getMax()
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
|
||||
namespace App\Filament\Tables\Columns;
|
||||
|
||||
use App\Models\OddsQualify;
|
||||
use Filament\Tables\Columns\Column;
|
||||
|
||||
class ColumnTq extends Column
|
||||
@@ -13,8 +12,6 @@ class ColumnTq extends Column
|
||||
|
||||
protected ?array $min;
|
||||
|
||||
protected $data;
|
||||
|
||||
protected ?array $bookmakers;
|
||||
|
||||
protected ?bool $has_data;
|
||||
@@ -33,23 +30,16 @@ class ColumnTq extends Column
|
||||
|
||||
public function loadData($record)
|
||||
{
|
||||
$this->data = OddsQualify::with('bookmaker')->where('event_id', $record->id)->get();
|
||||
$this->max['htq'] = $record->odds_tq->max('htq');
|
||||
$this->min['htq'] = $record->odds_tq->min('htq');
|
||||
|
||||
$this->max['htq'] = $this->data->max('htq');
|
||||
$this->min['htq'] = $this->data->min('htq');
|
||||
$this->max['atq'] = $record->odds_tq->max('atq');
|
||||
$this->min['atq'] = $record->odds_tq->min('atq');
|
||||
|
||||
$this->max['atq'] = $this->data->max('atq');
|
||||
$this->min['atq'] = $this->data->min('atq');
|
||||
$this->max['margin'] = $record->odds_tq->max('margin');
|
||||
$this->min['margin'] = $record->odds_tq->min('margin');
|
||||
|
||||
$this->max['margin'] = $this->data->max('margin');
|
||||
$this->min['margin'] = $this->data->min('margin');
|
||||
|
||||
$this->has_data = count($this->data) ? true : false;
|
||||
}
|
||||
|
||||
public function getData()
|
||||
{
|
||||
return $this->data;
|
||||
$this->has_data = count($record->odds_tq) ? true : false;
|
||||
}
|
||||
|
||||
public function getMax()
|
||||
|
||||
@@ -67,4 +67,59 @@ class Event extends Model
|
||||
{
|
||||
return $this->belongsTo(Element::class);
|
||||
}
|
||||
|
||||
public function odds_2way()
|
||||
{
|
||||
return $this->hasMany(Odds2way::class);
|
||||
}
|
||||
|
||||
public function odds_2way_s1()
|
||||
{
|
||||
return $this->hasMany(Odds2wayS1::class);
|
||||
}
|
||||
|
||||
public function odds_3way()
|
||||
{
|
||||
return $this->hasMany(Odds3way::class);
|
||||
}
|
||||
|
||||
public function odds_dc()
|
||||
{
|
||||
return $this->hasMany(OddsDc::class);
|
||||
}
|
||||
|
||||
public function odds_dnb()
|
||||
{
|
||||
return $this->hasMany(OddsDnb::class);
|
||||
}
|
||||
|
||||
public function odds_ggng()
|
||||
{
|
||||
return $this->hasMany(OddsGgng::class);
|
||||
}
|
||||
|
||||
public function odds_handicap()
|
||||
{
|
||||
return $this->hasMany(OddsHandicap::class);
|
||||
}
|
||||
|
||||
public function odds_handicap_q1()
|
||||
{
|
||||
return $this->hasMany(OddsHandicapQ1::class);
|
||||
}
|
||||
|
||||
public function odds_total()
|
||||
{
|
||||
return $this->hasMany(OddsTotal::class);
|
||||
}
|
||||
|
||||
public function odds_total_q1()
|
||||
{
|
||||
return $this->hasMany(OddsTotalQ1::class);
|
||||
}
|
||||
|
||||
public function odds_tq()
|
||||
{
|
||||
return $this->hasMany(OddsTq::class);
|
||||
}
|
||||
}
|
||||
@@ -4,9 +4,9 @@ namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class OddsQualify extends Model
|
||||
class OddsTq extends Model
|
||||
{
|
||||
protected $table = 'odds_qualify';
|
||||
protected $table = 'odds_tq';
|
||||
|
||||
protected $fillable = [
|
||||
'id',
|
||||
Reference in new issue
Block a user