diff --git a/backend/engine/engine.py b/backend/engine/engine.py index e24a3b95..f7a374e0 100644 --- a/backend/engine/engine.py +++ b/backend/engine/engine.py @@ -652,7 +652,8 @@ async def model_engine(body: PlanTriggerRequest): epc_records["original_epc"]["estimated"] = False prepared_epc = EPCRecord( - epc_records=epc_records, run_mode="newdata", cleaning_data=cleaning_data, address_metadata=addr + epc_records=epc_records, run_mode="newdata", cleaning_data=cleaning_data, + # address_metadata=addr Switched off to remove injecting landlord inputs ) input_properties.append( diff --git a/etl/epc/Record.py b/etl/epc/Record.py index defe13f4..8dbb5ba5 100644 --- a/etl/epc/Record.py +++ b/etl/epc/Record.py @@ -580,7 +580,22 @@ class EPCRecord: if existing is not None and v is not None and abs(existing - v) > 1: # 1m tolerance self.landlord_differences[k] = v else: - if v != self._prepared_epc.get(k) and (not pd.isnull(v)) and (not pd.isnull(self._prepared_epc.get(k))): + + # Check if something has been cleaned. We want to avoid triggering re-baselining if we cleaned + # a value. In the address meta, it will possibly contain the original value, so we'd pick up a + # diference if the original value was something to be cleaned, we clean that value and then end up + # comparing the original value to the new clean one + cleaned_value = self._prepared_epc.get(k) + original_value = self.original_epc.get(k.replace("_", "-")) + + # We check if the value has been cleaned + if cleaned_value != original_value: + # The thing we want to compare against, is the original value + compare_to = original_value + else: + compare_to = cleaned_value + + if v != compare_to and (not pd.isnull(v)) and (not pd.isnull(self._prepared_epc.get(k))): self.landlord_differences[k] = v self._prepared_epc.update(self.landlord_differences)