@@ -728,14 +728,41 @@ def head_report(self):
728
728
pass
729
729
return report
730
730
731
+ @cached_property
732
+ def head_report_without_applied_diff (self ):
733
+ """
734
+ This is a variant to the head_report property without having an applied diff.
735
+ This is created because applying the diff calls the provider, which adds a
736
+ diff_totals key to the head_report object as well as adjusting the diff_total
737
+ values in each session. This variant should only be used if you are not using
738
+ any diff related data, as it saves an unnecessary request to the provider otherwise.
739
+ """
740
+ try :
741
+ report = report_service .build_report_from_commit (self .head_commit )
742
+ except minio .error .S3Error as e :
743
+ if e .code == "NoSuchKey" :
744
+ raise MissingComparisonReport ("Missing head report" )
745
+ else :
746
+ raise e
747
+
748
+ return report
749
+
731
750
@cached_property
732
751
def has_different_number_of_head_and_base_sessions (self ):
733
- log .info ("has_different_number_of_head_and_base_sessions - Start" )
734
- head_sessions = self .head_report .sessions
735
- base_sessions = self .base_report .sessions
736
- log .info (
737
- f"has_different_number_of_head_and_base_sessions - Retrieved sessions - head { len (head_sessions )} / base { len (base_sessions )} "
738
- )
752
+ """
753
+ This method checks if the head and the base have different number of sessions.
754
+ It makes use of the head_report_without_applied_diff property instead of the
755
+ head_report one as it doesn't need diff related data for this computation (see
756
+ the description of that property above for more context).
757
+ This method should be replaced with a direct call to the report_uploads table instead,
758
+ but leaving the implementation the same for now for consistency.
759
+ """
760
+ try :
761
+ head_sessions = self .head_report_without_applied_diff .sessions
762
+ base_sessions = self .base_report .sessions
763
+ except Exception :
764
+ return False
765
+
739
766
# We're treating this case as false since considering CFF's complicates the logic
740
767
if self ._has_cff_sessions (head_sessions ) or self ._has_cff_sessions (
741
768
base_sessions
@@ -746,12 +773,9 @@ def has_different_number_of_head_and_base_sessions(self):
746
773
# I feel this method should belong to the API Report class, but we're thinking of getting rid of that class soon
747
774
# In truth, this should be in the shared.Report class
748
775
def _has_cff_sessions (self , sessions ) -> bool :
749
- log .info (f"_has_cff_sessions - sessions count { len (sessions )} " )
750
776
for session in sessions .values ():
751
777
if session .session_type .value == "carriedforward" :
752
- log .info ("_has_cff_sessions - Found carriedforward" )
753
778
return True
754
- log .info ("_has_cff_sessions - No carriedforward" )
755
779
return False
756
780
757
781
@property
0 commit comments