From a3c3c598e23894c40be5f0d80a46dbcee7c0f721 Mon Sep 17 00:00:00 2001 From: Hannah Eslinger Date: Mon, 25 Nov 2024 21:22:19 -0700 Subject: [PATCH] Add derived columns to program setup (#4888) * Add derived columns to program setup * fix compliance calcs with derived cols * handle all exceptions --------- Co-authored-by: kflemin <2205659+kflemin@users.noreply.github.com> --- seed/models/compliance_metrics.py | 10 ++++++++++ .../seed/js/controllers/program_setup_controller.js | 4 ++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/seed/models/compliance_metrics.py b/seed/models/compliance_metrics.py index 27e06dd01b..98016a697c 100644 --- a/seed/models/compliance_metrics.py +++ b/seed/models/compliance_metrics.py @@ -195,6 +195,11 @@ def _calculate_compliance(self, the_property, bool_metric, metric_type): actual_col = self.actual_energy_column if metric_type == "energy" else self.actual_emission_column target_col = self.target_energy_column if metric_type == "energy" else self.target_emission_column actual_val = self._get_column_data(the_property, actual_col) + try: + actual_val = float(actual_val) + except Exception: + return "u" + if not isinstance(actual_val, numbers.Number): return "u" @@ -202,6 +207,11 @@ def _calculate_compliance(self, the_property, bool_metric, metric_type): return "y" if bool(actual_val) else "n" target_val = self._get_column_data(the_property, target_col) + try: + target_val = float(target_val) + except Exception: + return "u" + if not isinstance(target_val, numbers.Number): return "u" diff --git a/seed/static/seed/js/controllers/program_setup_controller.js b/seed/static/seed/js/controllers/program_setup_controller.js index edd64869a7..c7c85ca6a0 100644 --- a/seed/static/seed/js/controllers/program_setup_controller.js +++ b/seed/static/seed/js/controllers/program_setup_controller.js @@ -44,8 +44,8 @@ angular.module('SEED.controller.program_setup', []).controller('program_setup_co $scope.valid_column_data_types = ['number', 'float', 'integer', 'ghg', 'ghg_intensity', 'area', 'eui', 'boolean']; $scope.valid_x_axis_data_types = ['number', 'string', 'float', 'integer', 'ghg', 'ghg_intensity', 'area', 'eui', 'boolean']; - $scope.property_columns = _.reject(property_columns, (item) => item.related || !$scope.valid_column_data_types.includes(item.data_type)).sort((a, b) => naturalSort(a.displayName, b.displayName)); - $scope.x_axis_columns = _.reject(property_columns, (item) => item.related || !$scope.valid_x_axis_data_types.includes(item.data_type)).sort((a, b) => naturalSort(a.displayName, b.displayName)); + $scope.property_columns = _.reject(property_columns, (item) => (item.related || !$scope.valid_column_data_types.includes(item.data_type)) && item.derived_column == null).sort((a, b) => naturalSort(a.displayName, b.displayName)); + $scope.x_axis_columns = _.reject(property_columns, (item) => (item.related || !$scope.valid_x_axis_data_types.includes(item.data_type)) && item.derived_column == null).sort((a, b) => naturalSort(a.displayName, b.displayName)); $scope.x_axis_selection = ''; $scope.cycle_selection = ''; $scope.compliance_metrics_error = [];