From b2ef2eec3403f753016e3f94d888e9a7e9cec397 Mon Sep 17 00:00:00 2001 From: Florent Yvon Date: Tue, 26 Mar 2024 17:47:31 +0000 Subject: [PATCH] Updating traits count during release --- release/scripts/CreateRelease.py | 9 ++++++++- release/scripts/run_release_script.py | 1 + 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/release/scripts/CreateRelease.py b/release/scripts/CreateRelease.py index 9b38be81..2f14eb04 100644 --- a/release/scripts/CreateRelease.py +++ b/release/scripts/CreateRelease.py @@ -11,6 +11,7 @@ class CreateRelease: new_scores = {} new_performances = {} + new_traits = set() def __init__(self, release_tomorrow=None): self.release_tomorrow = release_tomorrow @@ -30,6 +31,7 @@ def update_data_to_release(self): by adding a date in the 'date_released' columns """ self.get_release_date() + previous_traits = set(Score.objects.values_list('trait_efo__id', flat=True).exclude(date_released__isnull=True).distinct()) #### Add release date for each publications and dependent models #### for publication in self.new_publications: publication.date_released = self.new_release_date @@ -42,6 +44,9 @@ def update_data_to_release(self): # Update date_release score.date_released = self.new_release_date score.save() + # Get new traits + score_traits = {efotrait.id for efotrait in score.trait_efo.all()} + self.new_traits.update(score_traits.difference(previous_traits)) # Performances performances_list = Performance.objects.filter(date_released__isnull=True, publication=publication) @@ -55,12 +60,13 @@ def update_data_to_release(self): def create_new_release(self): """ Create new release instance and save it in the database """ #### Create new release instance #### - release_notes = 'This release contains {} new Score(s), {} new Publication(s) and {} new Performance metric(s)'.format(len(self.new_scores.keys()), len(self.new_publications), len(self.new_performances.keys())) + release_notes = 'This release contains {} new Score(s), {} new Publication(s), {} new Performance metric(s) and {} new Trait(s)'.format(len(self.new_scores.keys()), len(self.new_publications), len(self.new_performances.keys()), len(self.new_traits)) release = Release.objects.create( date=self.new_release_date, performance_count=len(self.new_performances.keys()), publication_count=len(self.new_publications), score_count=len(self.new_scores.keys()), + efotrait_count=len(self.new_traits), notes=release_notes ) return release @@ -123,6 +129,7 @@ def run(): print(', '.join(release.new_scores.keys())) print("Number of new Publications: "+str(new_release.publication_count)) print("Number of new Performances: "+str(new_release.performance_count)) + print("Number of new Traits: " + str(new_release.efotrait_count)) # Scores scores_direct = Score.objects.filter(date_released__isnull=True) diff --git a/release/scripts/run_release_script.py b/release/scripts/run_release_script.py index 266c281f..338bb393 100644 --- a/release/scripts/run_release_script.py +++ b/release/scripts/run_release_script.py @@ -181,6 +181,7 @@ def call_create_release(): output_report(', '.join(release.new_scores.keys())) output_report("Number of new Publications: "+str(new_release.publication_count)) output_report("Number of new Performances: "+str(new_release.performance_count)) + output_report("Number of new Traits: " + str(new_release.efotrait_count)) if new_release.score_count == 0 or new_release.publication_count == 0 or new_release.performance_count == 0: error_report("at least one of the main components (Score, Publication or Performance Metrics) hasn't a new entry this release")