Skip to content

Commit

Permalink
explicitly convert remote place values to string (#249)
Browse files Browse the repository at this point in the history
* Update remote-place-cache.ts

* Update remote-place-cache.ts

* test

* 2.1.2
  • Loading branch information
freddieptf authored Feb 10, 2025
1 parent c3e5a25 commit 985d18d
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 11 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "cht-user-management",
"version": "2.1.1",
"version": "2.1.2",
"main": "dist/index.js",
"dependencies": {
"@bull-board/api": "^5.17.0",
Expand Down
4 changes: 2 additions & 2 deletions scripts/deploy/values/users-chis-civ.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ cht-user-management:
enabled: true
image:
repository: public.ecr.aws/medic/cht-user-management
tag: "2.1.1" # Set this to the version of the docker image
tag: "2.1.2" # Set this to the version of the docker image

# Environment variablues to set in the pod, for example:
# env:
Expand Down Expand Up @@ -51,7 +51,7 @@ cht-user-management-worker:
replicaCount: 1
image:
repository: public.ecr.aws/medic/cht-user-management-worker
tag: "2.1.1"
tag: "2.1.2"
env:
NODE_ENV: production
REDIS_HOST: users-chis-civ-redis-master.users-chis-prod.svc.cluster.local
Expand Down
4 changes: 2 additions & 2 deletions scripts/deploy/values/users-chis-ke.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ cht-user-management:
enabled: true
image:
repository: public.ecr.aws/medic/cht-user-management
tag: "2.1.1" # Set this to the version of the docker image
tag: "2.1.2" # Set this to the version of the docker image

# Environment variablues to set in the pod, for example:
# env:
Expand Down Expand Up @@ -51,7 +51,7 @@ cht-user-management-worker:
replicaCount: 1
image:
repository: public.ecr.aws/medic/cht-user-management-worker
tag: "2.1.1"
tag: "2.1.2"
env:
NODE_ENV: production
REDIS_HOST: users-chis-ke-redis-master.users-chis-prod.svc.cluster.local
Expand Down
4 changes: 2 additions & 2 deletions scripts/deploy/values/users-chis-tg.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ cht-user-management:
enabled: true
image:
repository: public.ecr.aws/medic/cht-user-management
tag: "2.1.1" # Set this to the version of the docker image
tag: "2.1.2" # Set this to the version of the docker image

# Environment variablues to set in the pod, for example:
# env:
Expand Down Expand Up @@ -51,7 +51,7 @@ cht-user-management-worker:
replicaCount: 1
image:
repository: public.ecr.aws/medic/cht-user-management-worker
tag: "2.1.1"
tag: "2.1.2"
env:
NODE_ENV: production
REDIS_HOST: users-chis-tg-redis-master.users-chis-prod.svc.cluster.local
Expand Down
4 changes: 2 additions & 2 deletions src/lib/remote-place-cache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,15 +95,15 @@ export default class RemotePlaceCache {
private static convertContactToRemotePlace(doc: any, uniqueKeyProperties: ContactProperty[], hierarchyLevel: HierarchyConstraint): RemotePlace {
const uniqueKeyStringValues: FormattedPropertyCollection = {};
for (const property of uniqueKeyProperties) {
const value = doc[property.property_name];
const value = doc[property.property_name]?.toString();
if (value) {
uniqueKeyStringValues[property.property_name] = new RemotePlacePropertyValue(value, property);
}
}

return {
id: doc._id,
name: new RemotePlacePropertyValue(doc.name, hierarchyLevel),
name: new RemotePlacePropertyValue(doc.name?.toString(), hierarchyLevel),
placeType: hierarchyLevel.contact_type,
lineage: this.extractLineage(doc),
uniquePlaceValues: uniqueKeyStringValues,
Expand Down
19 changes: 19 additions & 0 deletions test/lib/remote-place-cache.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,4 +81,23 @@ describe('lib/remote-place-cache.ts', () => {
chtApi.chtSession.authInfo.domain = 'http://other';
RemotePlaceCache.clear(chtApi, 'other');
});

it('unique key properties', async () => {
const chtApi = mockChtApi([{_id: 'id', name: 1 }]);
const contactType = mockSimpleContactType('string', undefined);
contactType.place_properties.find(p => p.property_name === 'name').unique = 'all';
const contactTypeAsHierarchyLevel: HierarchyConstraint = {
contact_type: contactType.name,
property_name: 'level',
friendly_name: 'pretend another ContactType needs this',
type: 'name',
required: true,
level: 0,
};
try {
await RemotePlaceCache.getRemotePlaces(chtApi, contactType, contactTypeAsHierarchyLevel);
} catch (e) {
expect(e).to.be.undefined;
}
});
});

0 comments on commit 985d18d

Please sign in to comment.