From 82da89cd951dd00fad3cb306f55ac1fab02f8bb2 Mon Sep 17 00:00:00 2001 From: Michael Wood Date: Wed, 22 Nov 2023 17:42:38 +0000 Subject: [PATCH] lib360dataquality: Regression on incorrectly rounded value Since it was rounding to the nearest int on a value range between 0.0-1.0 this was pushing the value to 0 incorrectly. Remove this rounding and leave it to the data presentation in templates etc. Fixes: https://github.com/ThreeSixtyGiving/dataquality/issues/93 --- lib360dataquality/cove/threesixtygiving.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib360dataquality/cove/threesixtygiving.py b/lib360dataquality/cove/threesixtygiving.py index 194a40c..032bb02 100644 --- a/lib360dataquality/cove/threesixtygiving.py +++ b/lib360dataquality/cove/threesixtygiving.py @@ -562,8 +562,7 @@ def get_heading_count(self, test_class_type): if total < 1: total = 1 - self.grants_percentage = round(self.count / total, 1) - heading_percentage = "{:.0%}".format(self.grants_percentage) + self.grants_percentage = self.count / total # Return conditions @@ -574,10 +573,11 @@ def get_heading_count(self, test_class_type): self.grants_percentage = 1.0 return f"1 {self.relevant_grant_type}".strip() - if self.count < 5: + if self.count <= 5: return f"{self.count} {self.relevant_grant_type}".strip() - return f"{heading_percentage} of {self.relevant_grant_type}".strip() + heading_percentage = "{:.0%}".format(self.grants_percentage) + return f"{heading_percentage} ({self.count}) of {self.relevant_grant_type}".strip() def format_heading_count(self, message, test_class_type=None, verb="have"): """Build a string with count of grants plus message