Skip to content

Commit

Permalink
Improve query for building the EIS lookup table for MVEA canvas (CFM-…
Browse files Browse the repository at this point in the history
…417)
  • Loading branch information
arlen committed Mar 19, 2026
1 parent 5d75b96 commit c7992d8
Showing 1 changed file with 15 additions and 14 deletions.
29 changes: 15 additions & 14 deletions app/src/Controller/PeopleController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit c7992d8

Please sign in to comment.