-
Notifications
You must be signed in to change notification settings - Fork 256
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use a global grouping sequence for analytics display
Also regenerated database procs.
- Loading branch information
1 parent
c8ba83a
commit 1bc696c
Showing
18 changed files
with
720 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,8 +22,7 @@ | |
"port": "5000", | ||
"apiIdentifier": "api" | ||
}, | ||
"csetAnalyticsUrlAAAAAAAAAAA": "http://csetac:5210/api/analytics/maturity?", | ||
"csetAnalyticsUrl": "http://localhost:5002/api/analytics/maturitynew?", | ||
"csetAnalyticsUrl": "http://localhost:5002/api/analytics/maturity/bars?", | ||
"csetGithubApiUrl": "https://api.github.com/repos/cisagov/cset/releases/latest", | ||
"helpContactEmail": "[email protected]", | ||
"helpContactPhone": "", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
|
||
-- ============================================= | ||
-- Author: <Author,,Name> | ||
-- Create date: <Create Date,,> | ||
-- Description: <Description,,> | ||
-- ============================================= | ||
CREATE PROCEDURE [dbo].[FillAll] | ||
-- Add the parameters for the stored procedure here | ||
@Assessment_Id int | ||
AS | ||
BEGIN | ||
-- SET NOCOUNT ON added to prevent extra result sets from | ||
-- interfering with SELECT statements. | ||
SET NOCOUNT ON; | ||
|
||
-- Insert statements for procedure here | ||
exec FillEmptyMaturityQuestionsForAnalysis @assessment_id | ||
exec FillEmptyQuestionsForAnalysis @assessment_id | ||
END |
38 changes: 38 additions & 0 deletions
38
Database Scripts/Stored Procedures/FillEmptyMaturityQuestionsForModel.proc.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
|
||
-- ============================================= | ||
-- Author: Randy Woods | ||
-- Create date: 09/10/2024 | ||
-- Description: Create empty data for questions that have not been filled out. | ||
-- This version of the proc is designed for deliberately fleshing out SSG questions | ||
-- because their relevance is not determined by AVAILABLE_MATURITY_MODELS. | ||
-- ============================================= | ||
CREATE PROCEDURE [dbo].[FillEmptyMaturityQuestionsForModel] | ||
@Assessment_Id int, | ||
@Model_Id int | ||
AS | ||
BEGIN | ||
DECLARE @result int; | ||
begin | ||
BEGIN TRANSACTION; | ||
EXEC @result = sp_getapplock @Resource = '[Answer]', @LockMode = 'Exclusive'; | ||
INSERT INTO [dbo].[ANSWER] ([Question_Or_Requirement_Id],[Answer_Text],[Question_Type],[Assessment_Id]) | ||
select mq.Mat_Question_Id,Answer_Text = 'U', Question_Type='Maturity', Assessment_Id = @Assessment_Id | ||
from [dbo].[MATURITY_QUESTIONS] mq | ||
where Maturity_Model_Id = @Model_Id | ||
and Mat_Question_Id not in | ||
(select Question_Or_Requirement_Id from [dbo].[ANSWER] | ||
where Assessment_Id = @Assessment_Id and Maturity_Model_Id = @Model_Id) | ||
IF @result = -3 | ||
BEGIN | ||
ROLLBACK TRANSACTION; | ||
END | ||
ELSE | ||
BEGIN | ||
EXEC sp_releaseapplock @Resource = '[Answer]'; | ||
COMMIT TRANSACTION; | ||
END | ||
end | ||
|
||
END | ||
/****** Object: StoredProcedure [dbo].[FillEmptyQuestionsForAnalysis] Script Date: 12/16/2020 11:01:33 AM ******/ | ||
SET ANSI_NULLS ON |
28 changes: 28 additions & 0 deletions
28
Database Scripts/Stored Procedures/GetAnswerCountsForGroupings.proc.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
|
||
-- ============================================= | ||
-- Author: WOODRK | ||
-- Create date: 8/29/2024 | ||
-- Description: Generically return answer counts for all groupings in | ||
-- an assessment's maturity model | ||
-- ============================================= | ||
CREATE PROCEDURE [dbo].[GetAnswerCountsForGroupings] | ||
@assessmentId int | ||
AS | ||
BEGIN | ||
-- SET NOCOUNT ON added to prevent extra result sets from | ||
-- interfering with SELECT statements. | ||
SET NOCOUNT ON; | ||
|
||
exec [FillEmptyMaturityQuestionsForAnalysis] @assessmentId | ||
|
||
select Title, Sequence, Grouping_Id, Parent_Id, Answer_Text, count(*) as AnsCount | ||
from ( | ||
select mg.Title, mg.Sequence, mg.grouping_id, mg.Parent_Id, a.Answer_Text | ||
from answer a | ||
left join maturity_questions mq on a.Question_Or_Requirement_Id = mq.Mat_Question_Id and a.Question_Type = 'maturity' | ||
left join maturity_groupings mg on mq.Grouping_Id = mg.Grouping_Id | ||
where assessment_id = @assessmentId | ||
) b | ||
group by title, sequence, grouping_id, parent_id, answer_text | ||
order by sequence, answer_text | ||
END |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
Database Scripts/Stored Procedures/GetMaturityComparisonBestToWorst.proc.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
|
||
-- ============================================= | ||
-- Author: WOODRK | ||
-- Create date: 8/29/2024 | ||
-- Description: | ||
-- ============================================= | ||
CREATE PROCEDURE [dbo].[GetMaturityComparisonBestToWorst] | ||
@assessment_id int | ||
AS | ||
BEGIN | ||
-- SET NOCOUNT ON added to prevent extra result sets from | ||
-- interfering with SELECT statements. | ||
SET NOCOUNT ON; | ||
|
||
|
||
SELECT Assessment_Id, | ||
AssessmentName = Alias, | ||
Name = Title, | ||
* | ||
--AlternateCount = [I], | ||
--AlternateValue = Round(((cast(([I]) as float)/isnull(nullif(Total,0),1)))*100,2), | ||
--NaCount = [S], | ||
--NaValue = Round(((cast(([S]) as float)/isnull(nullif(Total,0),1)))*100,2), | ||
--NoCount = [N], | ||
--NoValue = Round(((cast(([N]) as float)/isnull(nullif(Total,0),1)))*100,2), | ||
--TotalCount = Total, | ||
--TotalValue = Total, | ||
--UnansweredCount = [U], | ||
--UnansweredValue = Round(cast([U] as float)/Total*100,2), | ||
--YesCount = [Y], | ||
--YesValue = Round((cast(([Y]) as float)/isnull(nullif(Total,0),1))*100,2), | ||
--Value = Round(((cast(([Y]+ isnull([I],0)) as float)/isnull(nullif((Total-[S]),0),1)))*100,2) | ||
FROM | ||
( | ||
select b.Assessment_Id, f.Alias, b.Title, b.Answer_Text, isnull(c.Value,0) as Value, | ||
Total = sum(c.Value) over(partition by b.Assessment_Id, b.Title) | ||
from | ||
(select distinct a.[Assessment_Id], g.Title, l.answer_Text | ||
from answer_lookup l, (select * from Answer_Maturity where assessment_id = @assessment_id) a | ||
join [MATURITY_QUESTIONS] q on a.Question_Or_Requirement_Id = q.Mat_Question_Id | ||
join MATURITY_GROUPINGS g on q.Grouping_Id = g.Grouping_Id | ||
) b left join | ||
(select a.Assessment_Id, g.Title, a.Answer_Text, count(a.answer_text) as Value | ||
from (select * from Answer_Maturity where assessment_id = @assessment_id) a | ||
join [MATURITY_QUESTIONS] q on a.Question_Or_Requirement_Id = q.Mat_Question_Id | ||
join MATURITY_GROUPINGS g on q.Grouping_Id = g.Grouping_Id | ||
group by Assessment_Id, g.Title, a.Answer_Text) c | ||
on b.Assessment_Id = c.Assessment_Id and b.Title = c.Title and b.Answer_Text = c.Answer_Text | ||
join ASSESSMENTS f on b.Assessment_Id = f.Assessment_Id | ||
) p | ||
|
||
|
||
PIVOT | ||
( | ||
sum(value) | ||
FOR answer_text IN ( [Y],[I],[S],[N],[U] ) | ||
) AS pvt | ||
END |
Oops, something went wrong.