Speed up Queue board loads by dropping sync and gate side effects.
Deploy Ladill Care / deploy (push) Successful in 1m22s
Deploy Ladill Care / deploy (push) Successful in 1m22s
Stop issuing missing tickets and refreshing financial gates on every GET; eager-load advances, cap board rows, and cache specialty department maps. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -94,6 +94,22 @@ class Visit extends Model
|
||||
return $this->hasMany(VisitStageAdvance::class, 'visit_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* Active or blocked advance for the visit's current workflow stage.
|
||||
* Prefer this for eager-loaded queue board filtering (avoids N+1 currentAdvance queries).
|
||||
*/
|
||||
public function currentStageAdvance(): HasOne
|
||||
{
|
||||
return $this->hasOne(VisitStageAdvance::class, 'visit_id')
|
||||
->ofMany(
|
||||
['id' => 'max'],
|
||||
fn ($query) => $query->whereIn('status', [
|
||||
VisitStageAdvance::STATUS_ACTIVE,
|
||||
VisitStageAdvance::STATUS_BLOCKED,
|
||||
]),
|
||||
);
|
||||
}
|
||||
|
||||
public function financialObligations(): HasMany
|
||||
{
|
||||
return $this->hasMany(FinancialObligation::class, 'visit_id');
|
||||
|
||||
Reference in New Issue
Block a user