Speed up Queue board loads by dropping sync and gate side effects.
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:
isaacclad
2026-07-18 19:50:03 +00:00
co-authored by Cursor
parent 93c7a71ee5
commit a5bbbe23b1
10 changed files with 512 additions and 76 deletions
+16
View File
@@ -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');