Skip to content

Commit

Permalink
Handle empty cycles on portfolio summary (#4554)
Browse files Browse the repository at this point in the history
* refactors for empty cycles

* precommit

* documentation

* formatting

* documentation

* documentation

---------

Co-authored-by: Hannah Eslinger <[email protected]>
  • Loading branch information
perryr16 and haneslinger authored Feb 29, 2024
1 parent 2f6053b commit 277ce23
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions seed/static/seed/js/controllers/portfolio_summary_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,11 @@ angular.module('BE.seed.controller.portfolio_summary', [])

get_paginated_properties(page, per_page, cycle_priority[1], access_level_instance_id, false, property_ids).then((result1) => {
properties = result1.results;
// if result0 returns fewer properties than result1, use result1 for ui-grid config
if (result1.pagination.num_pages > $scope.inventory_pagination.num_pages) {
baseline_first = !baseline_first
$scope.inventory_pagination = result1.pagination
}
combined_result[cycle_priority[1].id] = properties;
get_all_labels();
set_grid_options(combined_result);
Expand Down Expand Up @@ -437,10 +442,14 @@ angular.module('BE.seed.controller.portfolio_summary', [])
};

const combine_properties = (current, baseline) => {
// Given 2 properties, find non null values and combine into a single property
// Given 2 properties, find non null values and combine into a single property (favoring baseline if baseline_first)
const [a, b] = baseline_first ? [baseline, current] : [current, baseline];
const c = {};
Object.keys(a).forEach((key) => c[key] = a[key] !== null ? a[key] : b[key]);
const c = {...b};
Object.keys(a).forEach(key => {
if (a[key] !== null && a[key] !== undefined) {
c[key] = a[key]
}
});
return c;
};

Expand Down

0 comments on commit 277ce23

Please sign in to comment.