-
Notifications
You must be signed in to change notification settings - Fork 437
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
Fix bug in clinical-density-plot endpoint when mixing sample and patient attributes #8884
Conversation
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.
just a few small changes. looks good to me.
List<Sample> samplesForPatient = patientToSamples.get( | ||
d.getPatientId() | ||
).get(d.getStudyId()); | ||
if (samplesForPatient != null) { | ||
for (Sample s: samplesForPatient) { | ||
ClinicalData newData = new ClinicalData(); | ||
newData.setAttrId(d.getAttrId()); | ||
newData.setPatientId(d.getPatientId()); | ||
newData.setStudyId(d.getStudyId()); | ||
newData.setAttrValue(d.getAttrValue()); | ||
newData.setSampleId(s.getStableId()); | ||
sampleClinicalDataList.add(newData); | ||
} | ||
} |
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.
If you wanted to cut down on your nesting, you could do something like this:
List<Sample> samplesForPatient = patientToSamples.get( | |
d.getPatientId() | |
).get(d.getStudyId()); | |
if (samplesForPatient != null) { | |
for (Sample s: samplesForPatient) { | |
ClinicalData newData = new ClinicalData(); | |
newData.setAttrId(d.getAttrId()); | |
newData.setPatientId(d.getPatientId()); | |
newData.setStudyId(d.getStudyId()); | |
newData.setAttrValue(d.getAttrValue()); | |
newData.setSampleId(s.getStableId()); | |
sampleClinicalDataList.add(newData); | |
} | |
} | |
List<Sample> samplesForPatient = patientToSamples | |
.get(d.getPatientId()) | |
.getOrDefault(d.getStudyId(), new ArrayList<>()); | |
for (Sample s: samplesForPatient) { | |
ClinicalData newData = new ClinicalData(); | |
newData.setAttrId(d.getAttrId()); | |
newData.setPatientId(d.getPatientId()); | |
newData.setStudyId(d.getStudyId()); | |
newData.setAttrValue(d.getAttrValue()); | |
newData.setSampleId(s.getStableId()); | |
sampleClinicalDataList.add(newData); | |
} |
This is really six in one half a dozen in the other though.
…ent attributes New solution always returns counts in terms of samples Signed-off-by: Adam Abeshouse <abeshoua@mskcc.org>
a6455d6
to
6597b28
Compare
Kudos, SonarCloud Quality Gate passed! |
New solution always returns counts in terms of samples
Part of #8867