You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
At the end of Project::load_metadata, after a project, its samples and its libraries have been added to the db, sample and project aggregate values are updated (samples aggregate library values, and projects aggregate sample values). Project aggregate logic is split up into two methods - Project::update_project_modality_properties and Project::update_project_aggregate_properties.
Problem or idea
We should look to optimize the Project::update_project_aggregate_properties method from a code readability perspective by pulling out the assignment of values from the for sample in self.samples.all() loop, and to assign them directly via querying for the different attribute values. The additional querying is not as performant as the current implementation of a single for loop, but the actual performance gain is negligible in our use case due the minimal set of attributes, which gives credence to a code readability optimization.
Solution or next step
defupdate_project_aggregate_properties(self):
""" The Project and ProjectSummary models cache aggregated sample metadata. We need to update these after any project's sample gets added/deleted. """
...
self.additional_metadata_keys=", ".join(sorted(set(sample.additional_metadata_keysforsampleinself.samples.all()), key=str.lower)
self.diagnoses=", ".join(sorted(set(sample.diagnosisforsampleinself.samples.all()))
...
self.save()
The text was updated successfully, but these errors were encountered:
Context
At the end of
Project::load_metadata
, after aproject
, itssamples
and itslibraries
have been added to the db,sample
andproject
aggregate values are updated (samples
aggregatelibrary
values, andprojects
aggregatesample
values).Project
aggregate logic is split up into two methods -Project::update_project_modality_properties
andProject::update_project_aggregate_properties
.Problem or idea
We should look to optimize the
Project::update_project_aggregate_properties
method from a code readability perspective by pulling out the assignment of values from thefor sample in self.samples.all()
loop, and to assign them directly via querying for the different attribute values. The additional querying is not as performant as the current implementation of a singlefor
loop, but the actual performance gain is negligible in our use case due the minimal set of attributes, which gives credence to a code readability optimization.Solution or next step
The text was updated successfully, but these errors were encountered: