-
Notifications
You must be signed in to change notification settings - Fork 4
Add EIS badges to Person Canvas redux (CFM-417) #371
base: develop
Are you sure you want to change the base?
Conversation
| $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) | ||
| ->toArray(); | ||
|
|
||
| $this->set('vv_external_identity_sources', $eisLookupTable); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I get nervous when joins are used, since we've historically had problems with joins not working correctly with ChangelogBehavior. This is also a very "SQL" way of looking at data. A more Cake-centric approach would be something like (I didn't test this exact syntax, in particular the combine path notation may need some debugging)
// Pull External Identities with External Identity Source information as associated records
$records = $extIdentities->find()->where(['person_id' => $personId])->contain(['ExtIdentitySourceRecords' => 'ExternalIdentitySources'])->all();
// Use Hash to pull a mapping of the record ID to the EIS description
$mapping = $records->combine('id', 'ext_identity_source_record.ext_identity_source.description')->toArray();
| // 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(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The eisLookupTable is now built using standard cakephp approaches. The filter() allows us to only return rows with EISes, allowing the returned array to be identical to the original join approach.
…ipt components (CFM-417)
c7992d8 to
aeef1d5
Compare
|
Rebased against the latest develop |
This PR adds the EIS badges to the Person Canvas MVEAs when they exist. With the addition of the extra field, it became apparent that the data on the MVEAs needed better structure. This PR addresses that as well by converting the MVEA layouts into tables.