Skip to content

Commit

Permalink
Removing sourceEntryIds from exports and downloads
Browse files Browse the repository at this point in the history
  • Loading branch information
jim-sheldon committed May 17, 2022
1 parent 997e260 commit c5be19b
Show file tree
Hide file tree
Showing 18 changed files with 109 additions and 111 deletions.
6 changes: 5 additions & 1 deletion data-serving/data-service/src/controllers/case.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,10 +124,11 @@ export class CasesController {
return;
}

// don't export any note
// don't export notes or sourceEntryIds
c.forEach((aCase: LeanDocument<CaseDocument>) => {
delete aCase.restrictedNotes;
delete aCase.notes;
delete aCase.caseReference.sourceEntryId;
});

res.json(await Promise.all(c.map((aCase) => dtoFromCase(aCase))));
Expand Down Expand Up @@ -232,6 +233,8 @@ export class CasesController {
doc = await cursor.next();
while (doc != null) {
delete doc.restrictedNotes;
delete doc.notes;
delete doc.caseReference.sourceEntryId;
const caseDTO = await dtoFromCase(doc);
const parsedCase = parseDownloadedCase(caseDTO);
const stringifiedCase = stringify([parsedCase], {
Expand All @@ -254,6 +257,7 @@ export class CasesController {
while (doc != null) {
delete doc.restrictedNotes;
delete doc.notes;
delete doc.caseReference.sourceEntryId;
const normalizedDoc = await denormalizeFields(doc);
if (!doc.hasOwnProperty('SGTF')) {
normalizedDoc.SGTF = 'NA';
Expand Down
7 changes: 7 additions & 0 deletions data-serving/data-service/test/controllers/case.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,13 @@ describe('GET', () => {
const res = await request(app).get(`/api/cases/${c._id}`).expect(200);
expect(res.body[0].notes).toBeUndefined();
});
it('should not show the sourceEntryId for a case', async () => {
const c = new Case(minimalCase);
c.caseReference.sourceEntryId = 'Sourcey McSourceFace';
await c.save();
const res = await request(app).get(`/api/cases/${c._id}`).expect(200);
expect(res.body[0].caseReference.sourceEntryId).toBeUndefined();
});
it('should convert age bucket to age range', async () => {
const c = new Case(minimalCase);
const bucket = await AgeBucket.findOne({});
Expand Down
Loading

0 comments on commit c5be19b

Please sign in to comment.