From aeef1d560f171fc9194a55143231bb54f57dc1d2 Mon Sep 17 00:00:00 2001 From: Arlen Johnson Date: Thu, 19 Mar 2026 17:23:40 -0400 Subject: [PATCH] Improve query for building the EIS lookup table for MVEA canvas (CFM-417) --- app/src/Controller/PeopleController.php | 29 +++++++++++++------------ 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/app/src/Controller/PeopleController.php b/app/src/Controller/PeopleController.php index c37e1ca81..7463ed198 100644 --- a/app/src/Controller/PeopleController.php +++ b/app/src/Controller/PeopleController.php @@ -95,20 +95,21 @@ public function beforeRender(\Cake\Event\EventInterface $event) { // This will be passed to the view and made available to the JavaScript components. $extIdentities = TableRegistry::getTableLocator()->get('ExternalIdentities'); $personId = $this->request->getParam('pass.0'); - $eisLookupTable = $extIdentities - ->find('list', [ - 'keyField' => 'id', - 'valueField' => 'description', - ]) - ->select([ - 'id' => 'ExternalIdentities.id', - 'description' => 'ExternalIdentitySources.description', - ]) - ->innerJoinWith('ExtIdentitySourceRecords.ExternalIdentitySources') - ->where([ - 'ExternalIdentities.person_id' => $personId, - ]) - ->enableHydration(false) + + // Pull External Identities with External Identity Source information as associated records + $records = $extIdentities + ->find() + ->where(['ExternalIdentities.person_id' => $personId]) + ->contain(['ExtIdentitySourceRecords' => ['ExternalIdentitySources']]) + ->all(); + + // Combine into a flat record id => EIS description lookup array + $eisLookupTable = (new \Cake\Collection\Collection($records)) + ->filter(function ($record) { + // Only include rows that actually have an EIS description + return !empty($record->ext_identity_source_record->external_identity_source->description); + }) + ->combine('id', 'ext_identity_source_record.external_identity_source.description') ->toArray(); $this->set('vv_external_identity_sources', $eisLookupTable);