SQL Queries - CAST Central Base - SQL Queries on Metrics - How to check the values of a quality measure for a module


Purpose of Query

 This page provides a query to check the values for a quality measure for a module.

Applicable CAST Version


Release
Yes/No
8.3.x (tick)
8.2.x (tick)
Applicable RDBMS
RDBMS
Yes/No
Oracle Server (question)
Microsoft SQL Server (question)
CSS3(tick)
CSS2 (tick)


Query for CSS

First confirm that the metric was properly calculated for the snapshot by using the following query.

Substitute  the metric_id and for the date add a date before the snapshot was run ( for date something like '2019-11-3'):

SELECT *
FROM   DSS_HISTORY dh
WHERE  dh.DESCRIPTION LIKE '%<metric_id>%'
AND    dh.ACTION_DATE    > '2019-11-30';

The results should look something like this (for metric_id 7128). It shows that the metric was properly calculated:

Query result example
Start DIAG_SCOPE_MOD_NBCOMMENTEDLOC -3 60005 61007 7128 2019-11-30 07:49:47.454 185009
End DIAG_SCOPE_MOD_NBCOMMENTEDLOC -3 60005 61007 7128 2019-11-30 07:49:48.141 185010
Start ADG_METRIC_VALUE_SCOPE -3 61007 7128 1 2019-11-30 07:49:48.141 185011
End ADG_METRIC_VALUE_SCOPE -3 61007 7128 1 2019-11-30 07:49:48.157 185012
Start Update COMPUTE_VALUE -3 61007 7128 0 2 2019-11-30 07:49:48.157 185013
End Update COMPUTE_VALUE -3 61007 7128 0 2 2019-11-30 07:49:48.157 185014

Now that we know it has been calculated  then we can get the module values for this quality measure with the following query, by providing the metric id for the quality measure:

SELECT ds.FUNCTIONAL_DATE ,
ds.SNAPSHOT_ID ,
ds.SNAPSHOT_NAME ,
dos.OBJECT_NAME AS MODULE_NAME,
dmr.METRIC_NUM_VALUE AS RATIO ,
dmrw.METRIC_NUM_VALUE AS WEIGHT
FROM DSS_SNAPSHOTS ds
JOIN DSS_METRIC_RESULTS dmr
ON dmr.SNAPSHOT_ID = ds.SNAPSHOT_ID
AND dmr.METRIC_ID = <metric_id>
AND dmr.METRIC_VALUE_INDEX = 1
JOIN DSS_OBJECTS dos
ON dos.OBJECT_ID = dmr.OBJECT_ID
AND dos.OBJECT_TYPE_ID = 20000
JOIN DSS_METRIC_RESULTS dmrw
ON dmrw.SNAPSHOT_ID = ds.SNAPSHOT_ID
AND dmrw.OBJECT_ID = dos.OBJECT_ID
AND dmrw.METRIC_ID = 10152
AND dmrw.METRIC_VALUE_INDEX = 1
ORDER BY ds.FUNCTIONAL_DATE,
dos.OBJECT_NAME;

This query will provide something like the following showing the date, snapshot_id, module name, value for the quality measure and the weight of the quality measure (missing items most likely are items which are below the quality measure threshold value in the assessment model):

Query result example
2017-12-21 00:00:00.0 6 snap6 mod2 2.7872502607718848 7482.0
2017-12-21 00:00:00.0 6 snap6 mod1 2.058106058941169 17067.0
2019-02-02 00:00:00.0 8 snap8 mod2 2.284890901605599 4907.0


Query for Oracle
Enter the SQL query
Query result example

Query result interpretation


Query for SQL server
Enter the SQL query
Query result example

Query result interpretation

Notes/comments


Related Pages