Skip to content

Commit

Permalink
90 Hide last modified by fields (#164)
Browse files Browse the repository at this point in the history
* Remove unnecessary fields from the data download

* remove logs

* Update tests for data download

* Update tests to check for url not id, which was removed
  • Loading branch information
stanislaw-zakrzewski authored Jan 22, 2025
1 parent 8c43846 commit dcd6a76
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 6 deletions.
20 changes: 17 additions & 3 deletions data-serving/data-service/src/controllers/case.ts
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,16 @@ export class CasesController {
init(): CasesController {
this.csvHeaders = caseFields;
this.csvHeaders = removeBlankHeader(this.csvHeaders);
// Remove columns that are internal to or meaningless outside Turnkey Curator App
this.csvHeaders = this.csvHeaders.filter(
(csvHeader) =>
![
'caseReference.sourceEntryId',
'caseReference.sourceId',
'caseReference.uploadIds',
'comment',
].includes(csvHeader),
);
this.csvHeaders.sort((a, b) =>
a.localeCompare(b, undefined, { sensitivity: 'base' }),
);
Expand Down Expand Up @@ -359,11 +369,15 @@ export class CasesController {
cast: {
date: (value: Date) => {
if (value) {
return new Date(value).toISOString().split('T')[0];
return new Date(value)
.toISOString()
.split('T')[0];
}
return value;
},
}
boolean: (value: boolean) =>
value ? 'TRUE' : 'FALSE',
},
});
res.write(stringifiedCase);
doc = await cursor.next();
Expand Down Expand Up @@ -784,7 +798,7 @@ export class CasesController {
} as CaseDTO;

const c = fillEmpty(new Day0Case(await caseFromDTO(receivedCase)));
c.set({'events.dateLastModified': currentDate});
c.set({ 'events.dateLastModified': currentDate });

let result;
if (req.query.validate_only) {
Expand Down
6 changes: 3 additions & 3 deletions data-serving/data-service/test/controllers/case.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1048,16 +1048,16 @@ describe('download', () => {
.readFileSync(destination)
.toString('utf-8');
expect(text).toContain(
'_id,caseReference.additionalSources,caseReference.isGovernmentSource,caseReference.sourceEntryId,caseReference.sourceId,caseReference.sourceUrl,caseReference.uploadIds,caseStatus,comment,demographics.ageRange.end,demographics.ageRange.start,demographics.gender,demographics.healthcareWorker,demographics.occupation,events.confirmationMethod,events.dateAdmissionICU,events.dateConfirmation,events.dateDeath,events.dateDischargeHospital,events.dateDischargeICU,events.dateEntry,events.dateHospitalization,events.dateIsolation,events.dateLastModified,events.dateOfFirstConsult,events.dateOnset,events.dateRecovered,events.dateReported,events.homeMonitoring,events.hospitalized,events.intensiveCare,events.isolated,events.outcome,events.reasonForHospitalization,genomeSequences.accessionNumber,genomeSequences.genomicsMetadata,location.admin1,location.admin2,location.admin3,location.country,location.countryISO3,location.location,location.query,pathogen,preexistingConditions.coInfection,preexistingConditions.preexistingCondition,preexistingConditions.pregnancyStatus,preexistingConditions.previousInfection,symptoms,transmission.contactAnimal,transmission.contactComment,transmission.contactId,transmission.contactSetting,transmission.contactWithCase,transmission.transmission,travelHistory.travelHistory,travelHistory.travelHistoryCountry,travelHistory.travelHistoryEntry,travelHistory.travelHistoryLocation,travelHistory.travelHistoryStart,vaccination.vaccination,vaccination.vaccineDate,vaccination.vaccineName,vaccination.vaccineSideEffects',
'_id,caseReference.additionalSources,caseReference.isGovernmentSource,caseReference.sourceUrl,caseStatus,demographics.ageRange.end,demographics.ageRange.start,demographics.gender,demographics.healthcareWorker,demographics.occupation,events.confirmationMethod,events.dateAdmissionICU,events.dateConfirmation,events.dateDeath,events.dateDischargeHospital,events.dateDischargeICU,events.dateEntry,events.dateHospitalization,events.dateIsolation,events.dateLastModified,events.dateOfFirstConsult,events.dateOnset,events.dateRecovered,events.dateReported,events.homeMonitoring,events.hospitalized,events.intensiveCare,events.isolated,events.outcome,events.reasonForHospitalization,genomeSequences.accessionNumber,genomeSequences.genomicsMetadata,location.admin1,location.admin2,location.admin3,location.country,location.countryISO3,location.location,location.query,pathogen,preexistingConditions.coInfection,preexistingConditions.preexistingCondition,preexistingConditions.pregnancyStatus,preexistingConditions.previousInfection,symptoms,transmission.contactAnimal,transmission.contactComment,transmission.contactId,transmission.contactSetting,transmission.contactWithCase,transmission.transmission,travelHistory.travelHistory,travelHistory.travelHistoryCountry,travelHistory.travelHistoryEntry,travelHistory.travelHistoryLocation,travelHistory.travelHistoryStart,vaccination.vaccination,vaccination.vaccineDate,vaccination.vaccineName,vaccination.vaccineSideEffects',
);
expect(text).toContain(String(c._id));
expect(text).toContain(c.caseStatus);
expect(text).toContain('2025-01-12');
expect(text).toContain(c.caseReference.sourceId);
expect(text).toContain(c.caseReference.sourceUrl);
expect(text).toContain(String(c2._id));
expect(text).toContain(c2.caseStatus);
expect(text).toContain('2025-01-13');
expect(text).toContain(c2.caseReference.sourceId);
expect(text).toContain(c2.caseReference.sourceUrl);

resolve();
});
Expand Down

0 comments on commit dcd6a76

Please sign in to comment.