| @@ -26,8 +26,26 @@ | ||
| 26 | 26 | public function getSearchableFields(){ |
| 27 | 27 | return $this->searchable; |
| 28 | 28 | } |
| 29 | 29 | |
| 30 | + /** | |
| 31 | + * Agent ids, resolved once per request. Reporting filters on this list | |
| 32 | + * rather than whereHas('person', ...), which drove those queries off | |
| 33 | + * fs_persons (no person_type index) and cost them their date range. | |
| 34 | + * | |
| 35 | + * @return array | |
| 36 | + */ | |
| 37 | + public static function getAgentIds() | |
| 38 | + { | |
| 39 | + static $agentIds = null; | |
| 40 | + | |
| 41 | + if (is_null($agentIds)) { | |
| 42 | + $agentIds = array_map('intval', static::query()->pluck('id')->all()); | |
| 43 | + } | |
| 44 | + | |
| 45 | + return $agentIds; | |
| 46 | + } | |
| 47 | + | |
| 30 | 48 | public static function boot() |
| 31 | 49 | { |
| 32 | 50 | parent::boot(); |
| 33 | 51 | |