update
This commit is contained in:
@@ -35,17 +35,26 @@ SELECT
|
||||
WHEN LOWER(ap.test_Rating) NOT IN ('pass', 'p', 'comply', 'complies', 'fail', 'f', 'doesn\'t comply') THEN 1
|
||||
ELSE 0
|
||||
END) AS data_analyses,
|
||||
GREATEST(0, 10 - (
|
||||
SUM(
|
||||
CASE
|
||||
WHEN LOWER(ap.test_Rating) IN ('fail', 'f', 'doesn\'t comply') THEN
|
||||
COALESCE(asv.severity, 1) *
|
||||
CASE WHEN COALESCE(asv.is_legal, 'N') = 'Y' THEN 1.5 ELSE 1.0 END
|
||||
ELSE 0
|
||||
END
|
||||
) * (1 + SUM(CASE WHEN LOWER(ap.test_Rating) IN ('fail', 'f', 'doesn\'t comply') THEN 1 ELSE 0 END) / NULLIF(COUNT(ap.idAnalysis_Project), 0))
|
||||
/ NULLIF(COUNT(ap.idAnalysis_Project), 0) * 100
|
||||
)) AS rating,
|
||||
CASE
|
||||
WHEN SUM(CASE WHEN LOWER(ap.test_Rating) IN ('fail', 'f', 'doesn\'t comply') THEN 1 ELSE 0 END) = 0
|
||||
AND SUM(CASE WHEN LOWER(ap.test_Rating) NOT IN ('pass', 'p', 'comply', 'complies', 'fail', 'f', 'doesn\'t comply') THEN 1 ELSE 0 END) = 0
|
||||
THEN 100
|
||||
ELSE GREATEST(0, 100 - (
|
||||
SUM(
|
||||
CASE
|
||||
WHEN LOWER(ap.test_Rating) IN ('fail', 'f', 'doesn\'t comply') THEN
|
||||
POWER(COALESCE(asv.severity, 1), 2) *
|
||||
CASE WHEN COALESCE(asv.is_legal, 'N') = 'Y' THEN 2.0 ELSE 1.0 END
|
||||
ELSE 0
|
||||
END
|
||||
) / NULLIF(COUNT(ap.idAnalysis_Project), 0) * 100 *
|
||||
(1 + 2 * (SUM(CASE WHEN LOWER(ap.test_Rating) IN ('fail', 'f', 'doesn\'t comply') THEN 1 ELSE 0 END) / NULLIF(COUNT(ap.idAnalysis_Project), 0)))
|
||||
+ SUM(CASE
|
||||
WHEN LOWER(ap.test_Rating) NOT IN ('pass', 'p', 'comply', 'complies', 'fail', 'f', 'doesn\'t comply') THEN 0.3
|
||||
ELSE 0
|
||||
END)
|
||||
))
|
||||
END AS rating,
|
||||
NOW() AS calculation_date
|
||||
FROM products p
|
||||
JOIN reports r ON p.idproducts = r.idproducts
|
||||
@@ -61,7 +70,6 @@ ON DUPLICATE KEY UPDATE
|
||||
data_analyses = VALUES(data_analyses),
|
||||
rating = VALUES(rating),
|
||||
calculation_date = VALUES(calculation_date);
|
||||
|
||||
";
|
||||
|
||||
if ($conn->query($query) === TRUE) {
|
||||
|
||||
Reference in New Issue
Block a user