From 22d8e6d17a2ec4752f180245186409790e273593 Mon Sep 17 00:00:00 2001 From: Randy Woods Date: Mon, 2 Feb 2026 10:12:46 -0500 Subject: [PATCH] More SSG cleanup for multi-sector --- .../Demographic/DemographicBusinessTests.cs | 12 +++---- .../Demographic/DemographicBusiness.cs | 2 +- .../Maturity/CpgBusiness.cs | 34 +++++++++---------- .../CSETWebCore.Helpers/CpgStructure.cs | 2 +- .../MaturityStructureForModel.cs | 5 +++ .../Assessment/Demographics.cs | 6 +++- .../Controllers/DemographicsController.cs | 2 +- .../assessment-config-iod.component.ts | 1 + .../assessment-demographics.component.ts | 24 ++++++------- .../assessment-detail.component.ts | 1 + .../demographics-iod.component.ts | 10 ------ .../csi-service-demographics.component.ts | 9 ++++- .../cpg-practices/cpg-practices.component.ts | 4 ++- .../cpg-summary/cpg-summary.component.html | 10 +++--- .../cpg/cpg-summary/cpg-summary.component.ts | 3 +- .../src/app/models/assessment-info.model.ts | 4 +-- .../src/app/models/demographics-iod.model.ts | 2 +- .../cpg-deficiency.component.ts | 2 +- .../cpg/cpg-report/cpg-report.component.html | 4 +-- .../cpg/cpg-report/cpg-report.component.ts | 3 +- .../src/app/reports/edm/edm.component.ts | 4 +++ .../src/app/services/demographic.service.ts | 16 +++------ CSETWebNg/src/app/services/ssg.service.ts | 25 +------------- CSETWebNg/src/assets/i18n/en.json | 6 ++-- CSETWebNg/src/assets/i18n/reports/en.json | 6 ++-- 25 files changed, 91 insertions(+), 106 deletions(-) diff --git a/CSETWebApi/CSETWeb_Api/CSETWebCore.Business.Tests/Demographic/DemographicBusinessTests.cs b/CSETWebApi/CSETWeb_Api/CSETWebCore.Business.Tests/Demographic/DemographicBusinessTests.cs index 5ffe0b4622..9208fbeba8 100644 --- a/CSETWebApi/CSETWeb_Api/CSETWebCore.Business.Tests/Demographic/DemographicBusinessTests.cs +++ b/CSETWebApi/CSETWeb_Api/CSETWebCore.Business.Tests/Demographic/DemographicBusinessTests.cs @@ -249,7 +249,7 @@ public void GetDemographics_ReturnsBasicDemographics_WhenNoExtendedDataExists() // Assert Assert.NotNull(result); Assert.Equal(assessmentId, result.AssessmentId); - Assert.Empty(result.SsgSectorIds); + Assert.Empty(result.SsgModelIds); } [Fact] @@ -278,10 +278,10 @@ public void GetDemographics_LoadsSsgSectors_WhenSsgDataExists() // Assert Assert.NotNull(result); - Assert.Equal(3, result.SsgSectorIds.Count); - Assert.Contains(1, result.SsgSectorIds); - Assert.Contains(2, result.SsgSectorIds); - Assert.Contains(3, result.SsgSectorIds); + Assert.Equal(3, result.SsgModelIds.Count); + Assert.Contains(1, result.SsgModelIds); + Assert.Contains(2, result.SsgModelIds); + Assert.Contains(3, result.SsgModelIds); } [Fact] @@ -321,7 +321,7 @@ public void SaveDemographics_RemovesAndReplacesSSGSectors() var demographics = new Demographics { AssessmentId = assessmentId, - SsgSectorIds = new List { 1, 2, 3 } + SsgModelIds = new List { 1, 2, 3 } }; var existingSSG = new List diff --git a/CSETWebApi/CSETWeb_Api/CSETWebCore.Business/Demographic/DemographicBusiness.cs b/CSETWebApi/CSETWeb_Api/CSETWebCore.Business/Demographic/DemographicBusiness.cs index bc3b909cac..ff66f589e4 100644 --- a/CSETWebApi/CSETWeb_Api/CSETWebCore.Business/Demographic/DemographicBusiness.cs +++ b/CSETWebApi/CSETWeb_Api/CSETWebCore.Business/Demographic/DemographicBusiness.cs @@ -82,7 +82,7 @@ public Demographics GetDemographics(int assessmentId) } - demographics.SsgSectorIds.AddRange(new CpgBusiness(_context, "en").DetermineSsgModels(assessmentId)); + demographics.SsgModelIds.AddRange(new CpgBusiness(_context, "en").DetermineSsgModels(assessmentId)); diff --git a/CSETWebApi/CSETWeb_Api/CSETWebCore.Business/Maturity/CpgBusiness.cs b/CSETWebApi/CSETWeb_Api/CSETWebCore.Business/Maturity/CpgBusiness.cs index a3bb550459..2686a84951 100644 --- a/CSETWebApi/CSETWeb_Api/CSETWebCore.Business/Maturity/CpgBusiness.cs +++ b/CSETWebApi/CSETWeb_Api/CSETWebCore.Business/Maturity/CpgBusiness.cs @@ -123,33 +123,33 @@ private List InitializeSeries() /// /// Figures out if an SSG model is applicable as a bonus. /// The SSG is based on the assessment's sector. - /// Returns null if no SSG is applicable. + /// Returns an empty list if no SSG is applicable. /// /// public List DetermineSsgModels(int assessmentId) { - List list = []; - - var ddSectors = _context.ASSESSMENT_SECTOR_SUBSECTOR.Where(x => x.Assessment_Id == assessmentId).ToList(); - - foreach (var s in ddSectors) + var sectorToModelMap = new Dictionary { - // CHEMICAL - var chemicalSectors = new List() { 1, 19 }; - if (chemicalSectors.Contains((int)s.SectorId)) - { - list.Add(Constants.Constants.Model_SSG_CHEM); - } + { 1, Constants.Constants.Model_SSG_CHEM }, + { 19, Constants.Constants.Model_SSG_CHEM }, + { 13, Constants.Constants.Model_SSG_IT }, + { 28, Constants.Constants.Model_SSG_IT }, + }; + + var ssgModels = new HashSet(); + var sectors = _context.ASSESSMENT_SECTOR_SUBSECTOR + .Where(x => x.Assessment_Id == assessmentId) + .ToList(); - // INFORMATION TECHNOLOGY (IT) - var itSectors = new List() { 13, 28 }; - if (itSectors.Contains((int)s.SectorId)) + foreach (var sector in sectors) + { + if (sectorToModelMap.TryGetValue((int)sector.SectorId, out var modelId)) { - list.Add(Constants.Constants.Model_SSG_IT); + ssgModels.Add(modelId); } } - return list; + return ssgModels.ToList(); } diff --git a/CSETWebApi/CSETWeb_Api/CSETWebCore.Helpers/CpgStructure.cs b/CSETWebApi/CSETWeb_Api/CSETWebCore.Helpers/CpgStructure.cs index 9d6b58f5e5..e2ad645b94 100644 --- a/CSETWebApi/CSETWeb_Api/CSETWebCore.Helpers/CpgStructure.cs +++ b/CSETWebApi/CSETWeb_Api/CSETWebCore.Helpers/CpgStructure.cs @@ -110,7 +110,7 @@ private void LoadStructure() Top.ModelName = mm.Model_Name; Top.ModelId = (int)this.ModelId; - Top.TechDomain = _context.DETAILS_DEMOGRAPHICS.Where(x => x.DataItemName == "TECH-DOMAIN").FirstOrDefault()?.StringValue ?? null; + Top.TechDomain = _context.DETAILS_DEMOGRAPHICS.Where(x => x.Assessment_Id == this.AssessmentId && x.DataItemName == "TECH-DOMAIN").FirstOrDefault()?.StringValue ?? null; diff --git a/CSETWebApi/CSETWeb_Api/CSETWebCore.Helpers/MaturityStructureForModel.cs b/CSETWebApi/CSETWeb_Api/CSETWebCore.Helpers/MaturityStructureForModel.cs index fb5b7ad61b..d77c2f7070 100644 --- a/CSETWebApi/CSETWeb_Api/CSETWebCore.Helpers/MaturityStructureForModel.cs +++ b/CSETWebApi/CSETWeb_Api/CSETWebCore.Helpers/MaturityStructureForModel.cs @@ -195,6 +195,7 @@ private void GetSubgroups(object oParent, int? parentID) DisplayNumber = myQ.Question_Title, ParentQuestionId = myQ.Parent_Question_Id, QuestionType = myQ.Mat_Question_Type, + IsAnswerable = myQ.Is_Answerable, AnswerText = answer?.Answer_Text, AltAnswerText = answer?.Alternate_Justification, Comment = answer?.Comment, @@ -260,6 +261,9 @@ private List GetFollowupQuestions(int parentId) DisplayNumber = myQ.Question_Title, ParentQuestionId = myQ.Parent_Question_Id, QuestionType = myQ.Mat_Question_Type, + IsAnswerable = myQ.Is_Answerable, + AnswerText = answer?.Answer_Text, + AltAnswerText = answer?.Alternate_Justification, Comment = answer?.Comment ?? "", Options = GetOptions(myQ.Mat_Question_Id) }; @@ -323,6 +327,7 @@ private List