Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove source entry IDs from exports and downloads #2696

Merged
merged 1 commit into from
May 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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