From e59ae7a23cda150392705c0df15fa792515d3ff8 Mon Sep 17 00:00:00 2001 From: David Watkins Date: Thu, 27 Jul 2023 21:14:34 +0100 Subject: [PATCH 1/2] Change Initiatives: incomplete assessments filters #6687 --- .../ChangeInitiativeView.java | 20 +++ .../client/assessments/assessment-utils.js | 45 +---- .../change-initiative-section.html | 12 +- .../change-initiative-section.js | 155 ++++++++++++------ waltz-ng/client/change-initiative/index.js | 14 +- .../services/change-initiative-view-store.js | 57 +++++++ .../client/common/services/core-api-utils.js | 6 +- .../ChangeInitiativeViewService.java | 124 ++++++++++++++ .../api/ChangeInitiativeViewEndpoint.java | 60 +++++++ 9 files changed, 391 insertions(+), 102 deletions(-) create mode 100644 waltz-model/src/main/java/org/finos/waltz/model/change_initiative/ChangeInitiativeView.java create mode 100644 waltz-ng/client/change-initiative/services/change-initiative-view-store.js create mode 100644 waltz-service/src/main/java/org/finos/waltz/service/change_initiative/ChangeInitiativeViewService.java create mode 100644 waltz-web/src/main/java/org/finos/waltz/web/endpoints/api/ChangeInitiativeViewEndpoint.java diff --git a/waltz-model/src/main/java/org/finos/waltz/model/change_initiative/ChangeInitiativeView.java b/waltz-model/src/main/java/org/finos/waltz/model/change_initiative/ChangeInitiativeView.java new file mode 100644 index 0000000000..1c7240de5e --- /dev/null +++ b/waltz-model/src/main/java/org/finos/waltz/model/change_initiative/ChangeInitiativeView.java @@ -0,0 +1,20 @@ +package org.finos.waltz.model.change_initiative; + +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import org.finos.waltz.model.assessment_definition.AssessmentDefinition; +import org.finos.waltz.model.assessment_rating.AssessmentRating; +import org.finos.waltz.model.rating.RatingSchemeItem; +import org.immutables.value.Value; + +import java.util.Set; + +@Value.Immutable +@JsonSerialize(as=ImmutableChangeInitiativeView.class) +public abstract class ChangeInitiativeView { + + public abstract Set changeInitiatives(); + public abstract Set assessmentDefinitions(); + public abstract Set ratingSchemeItems(); + public abstract Set ratings(); + +} diff --git a/waltz-ng/client/assessments/assessment-utils.js b/waltz-ng/client/assessments/assessment-utils.js index d8069d6739..6549f2258b 100644 --- a/waltz-ng/client/assessments/assessment-utils.js +++ b/waltz-ng/client/assessments/assessment-utils.js @@ -17,8 +17,6 @@ */ import _ from "lodash"; import { indexRatingSchemes } from "../ratings/rating-utils"; -import { nest } from "d3-collection"; -import { grey } from "../common/colors"; import { refToString } from "../common/entity-utils"; import {CORE_API} from "../common/services/core-api-utils"; import {resolveResponses} from "../common/promise-utils"; @@ -70,48 +68,6 @@ export function mkEnrichedAssessmentDefinitions(definitions = [], } -export function mkAssessmentSummaries(definitions = [], schemes = [], ratings = [], total = 0) { - const indexedRatingSchemes = indexRatingSchemes(schemes); - const definitionsById = _.keyBy(definitions, d => d.id); - - const nestedRatings = nest() - .key(d => d.assessmentDefinitionId) - .key(d => d.ratingId) - .rollup(xs => xs.length) - .entries(ratings); - - return _ - .chain(nestedRatings) - .map(d => { - const definition = definitionsById[Number(d.key)]; - const assignedTotal = _.sumBy(d.values, v => v.value); - const values = _ - .chain(d.values) - .map(v => { - const propPath = [definition.ratingSchemeId, "ratingsById", v.key]; - const rating = _.get(indexedRatingSchemes, propPath); - return Object.assign({}, v, { rating, count: v.value }); - }) - .concat([{ - key: "z", - rating: { - id: -1, - name: "Not Provided", - color: grey - }, - count: _.max([0, total - assignedTotal]) - }]) - .filter(d => d.count > 0) - .value(); - - const extension = { definition, values }; - return Object.assign({}, d , extension); - }) - .orderBy(d => d.definition.name) - .value(); -} - - /** * Given a list of entities, a list of assessment ratings and a desired * rating will filter the list of entities accordingly @@ -154,6 +110,7 @@ export function filterByAssessmentRating(entities = [], * @param $q * @param serviceBroker * @param kind + * @param options * @param primaryOnly * @returns {*} */ diff --git a/waltz-ng/client/change-initiative/components/change-initiative-section/change-initiative-section.html b/waltz-ng/client/change-initiative/components/change-initiative-section/change-initiative-section.html index d7c27dacfa..f40d6b63e6 100644 --- a/waltz-ng/client/change-initiative/components/change-initiative-section/change-initiative-section.html +++ b/waltz-ng/client/change-initiative/components/change-initiative-section/change-initiative-section.html @@ -15,9 +15,19 @@ ~ See the License for the specific ~ --> + +