# CAST Engineering Dashboard - Information - How to compute the metric grade at application level

Purpose

The page describes the computation of the metric grade at application level. Computation need to be done on the Central Database.

Figure 1

This computation can be useful when comparing two snapshot results or when the metric grade at system/application/module level is not as expected (0, 4 or any other).

Applicable in CAST Version
Release
Yes/No
8.3.x
8.2.x
8.1.x
8.0.x
7.3.x
7.2.x
7.0.x
Applicable RDBMS
RDBMS
Yes/No
Oracle Server
Microsoft SQL Server
CSS2
CSS1
Details
1. Check that the Consolidation mode is used. This can be viewed in Expert mode in the CAST Management Studio > Assessment Model editor, under Quality Model > Consolidation Settings:
Figure 2
For more information on various consolidation modes see the documentation here: Defining consolidation weighting settings
2. Select from the below list depending on what is selected in Cast-MS Assessment Model -

## Full Application

The grade is calculated without any impact of modules by summing up the impact of the technical criteria associated with the business criteria.

Formula -

`the metric grade at application level = SUM (<WEIGHT_OF_TECHNICAL_CRITERION>*<METRIC_GRADE_OF_EACH_TECHNICAL_CRITERION at Application Level>)/SUM(<WEIGHT_OF_EACH_TECHNICAL_CRITERIA>)`

Example -

Figure 3

Sum (grade of each technical criteria * weight) / Sum (weight) = (2.71*1 + 3.01*1 + 4*1 + 4*1)/(1 + 1 + 1 + 1) = 13.72/4 = 3.43

When there are critical metrics involved :

When you have some critical metrics involved in the grade calculation then you need to take the minimum grade among those critical metrics grade and from the result of above formula.

For example:

From above screenshot, let's calculate the grade of TC-Programming Practices - Error and Exception Handling. There are 4 critical rules here with grade 1,1,1.95,2.81

=Min((8*1+8*1+7*1+8*1.21+7*1.95+6*2.81+7*3.12+8*3.21+8*4)/67),1,1,1.95,2.81)
=Min(2.13,1,1,1.95,2.81)
=1 ( Min value of above list of values)

## Average of Modules

The grade at application level is calculated with the impact of all modules taking a simple average of grades of the metric at module level.

Formula -

`the metric grade at application level = SUM(<METRIC_GRADE_OF_EACH_MODULE>)/NUMBER_OF_MODULES`

Example -

In the below screenshot we are calculating grade for Quality Rule - Avoid Open SQL Queries in Loops
Figure 4

Figure 5

the metric grade at application level = (1+1+1)/3 = 1

For business criteria and Technical criteria - Get the grades at module level from the Investigation Quality Model Drill down view of dashboard by clicking on each module displayed in the drop down box situated at the left top of the dashboard.

## Average of Modules (weighted by Business Value)

Formula -

`the metric grade at application level = SUM (<WEIGHT_OF_MODULE>*<METRIC_GRADE_OF_EACH_MODULE>)/SUM(<WEIGHT_OF_ALL_MODULES>)`

WEIGHT_OF_MODULE

1. Get the ID of the metric used for module weight using following query to be executed on central database -

Example
`SELECT OPTION_VALUE FROM SYS_SITE_OPTIONS WHERE OPTION_NAME = 'ADG_CENTRAL_WEIGHT_METRIC'`

Result - 10152 .
It means the metric bearing the ID 10152 is used as aggregation Weight

2. Get values of weight per module by running the below query on central database -

Example
```SELECT dmr.metric_num_value AS "WEIGHT",
ap.object_id         AS "MODULE_ID",
ap.object_name       AS "APP_NAME",
dmr.snapshot_id      AS "SNAPSHOT_ID"
FROM   dss_objects AP,
dss_metric_results DMR,
WHERE  dmr.metric_id = <weight_metric_id>
AND    dmr.metric_value_index = 1
AND    dmr.object_id = ap.object_id
AND    dl.previous_object_id = <application_id>
AND    dl.next_object_id = ap.object_id
AND    ap.object_type_id = 20000

Use this page to get the APPLICATION_ID - SQL Queries - CAST Central Base - Queries on applications - How to get the ID of the application.

Example -

Example
```SELECT DMR.metric_num_value AS "WEIGHT",
AP.object_id         AS "MODULE_ID",
AP.object_name       AS "APP_NAME",
DMR.snapshot_id      AS "SNAPSHOT_ID"
FROM   dss_objects AP,
dss_metric_results DMR,
WHERE  DMR.metric_id = 10152
AND DMR.metric_value_index = 1
AND DMR.object_id = AP.object_id
AND DL.previous_object_id = 3
AND DL.next_object_id = AP.object_id
AND AP.object_type_id = 20000
Result -

WEIGHT;MODULE_ID;APP_NAME;SNAPSHOT_ID
2;52251;"RECIPE BL";1
4;52252;"RECIPE COMMON";1
2;52253;"RECIPE DAL";1
1;52254;"RECIPE DATABASE";1
4;52255;"RECIPE MODEL";1
1;52256;"RECIPE SECURITY";1
4;52257;"RECIPE WEB";1```

Get the grades at module level from the Investigation Quality Model Drill down view of dashboard by clicking on each module displayed in the drop down box situated at the left top of the dashboard.

Figure 6

Calculation Example -

Weight from queryModule NameGrade From Dashboard
2RECIPE BL2
4RECIPE COMMON1
2RECIPE DAL1
1RECIPE DATABASE1
4RECIPE MODEL3
1RECIPE SECURITY2
4RECIPE WEB2