From 0c0ddab5c748503ce9a00e275b39b4daeda44b39 Mon Sep 17 00:00:00 2001 From: alejandravv <48628943+alejandravv@users.noreply.github.com> Date: Fri, 10 Jan 2020 13:12:05 +0100 Subject: [PATCH 1/2] Quality Model view (#118) * Refresh documentation * Solve issue #116 --- docs/asciidoc/index.html | 14 +++++----- .../resources/static/js/loadQualityModel.js | 26 +++++++++++++++---- 2 files changed, 28 insertions(+), 12 deletions(-) diff --git a/docs/asciidoc/index.html b/docs/asciidoc/index.html index 6bb376a8..5d14ade9 100644 --- a/docs/asciidoc/index.html +++ b/docs/asciidoc/index.html @@ -7328,7 +7328,7 @@

HTTP response

"value" : 0.4, "threshold" : 0.5, "category" : "category", - "date" : 1577127884741, + "date" : 1577130885162, "status" : "NEW", "reqAssociat" : true, "artefacts" : null @@ -8124,7 +8124,7 @@

HTTP response

{ "id" : 3, - "date" : 1577127884006, + "date" : 1577130884646, "requirement" : "The ratio of files without duplications should be at least 0.8", "description" : "The ratio of files without duplications should be at least the given value", "goal" : "Improve the quality of the source code", @@ -8313,7 +8313,7 @@

HTTP response

[ { "id" : 3, - "date" : 1577127889542, + "date" : 1577130890094, "requirement" : "The ratio of files without duplications should be at least 0.8", "description" : "The ratio of files without duplications should be at least the given value", "goal" : "Improve the quality of the source code", @@ -8328,7 +8328,7 @@

HTTP response

"value" : 0.4, "threshold" : 0.5, "category" : "category", - "date" : 1577127889542, + "date" : 1577130890094, "status" : "NEW", "reqAssociat" : true, "artefacts" : null @@ -8472,7 +8472,7 @@

HTTP response

{ "id" : 3, - "date" : 1577127889697, + "date" : 1577130890337, "requirement" : "The ratio of files without duplications should be at least 0.8", "description" : "The ratio of files without duplications should be at least the given value", "goal" : "Improve the quality of the source code", @@ -8995,7 +8995,7 @@

HTTP response

[ { "id" : 2, "type" : "ADD", - "date" : 1577127885859, + "date" : 1577130886173, "author" : null, "rationale" : "User comments", "patternId" : 100, @@ -10875,7 +10875,7 @@

HTTP response

diff --git a/src/main/resources/static/js/loadQualityModel.js b/src/main/resources/static/js/loadQualityModel.js index 53ab11c5..e9db10b4 100644 --- a/src/main/resources/static/js/loadQualityModel.js +++ b/src/main/resources/static/js/loadQualityModel.js @@ -38,6 +38,7 @@ function buildTree(strategicIndicators) { qmnodes.set(factor.id, node); if (!qmedges.has(factor.id+"-"+strategicIndicator.id)) qmedges.set(factor.id+"-"+strategicIndicator.id, createEdge(factor, strategicIndicator)); + var metricsWeights = sumMetricsWeights(factor.metrics); for (var k = 0; k < factor.metrics.length; k++) { var metric = factor.metrics[k]; @@ -45,17 +46,30 @@ function buildTree(strategicIndicators) { if (!qmnodes.has(metric.id)) qmnodes.set(metric.id, node); if (!qmedges.has(metric.id+"-"+factor.id)) - qmedges.set(metric.id+"-"+factor.id, createEdge(metric, factor)); + qmedges.set(metric.id+"-"+factor.id, createEdge(metric, factor, metricsWeights)); } } } displayData(Array.from(qmnodes.values()), Array.from(qmedges.values())); } +function sumMetricsWeights(elements){ + var totalWeight = 0; + for (var i = 0; i < elements.length; i++){ + totalWeight += parseFloat(elements[i].weight); + } + return totalWeight; +} + function createNode (element, color, colorBorder) { var value; if (element.valueDescription) value = element.valueDescription; - else value = element.value; + else { + if (element.weight && element.weight != 0) { + var w = parseFloat(element.weight); + value = parseFloat(element.value)/w; + } else value = element.value; + } return { data: { id: element.id, @@ -66,10 +80,12 @@ function createNode (element, color, colorBorder) { } } -function createEdge (source, target) { +function createEdge (source, target, aux) { // aux = sum metrics weights var weight = source.weight; - if (weight == 0) weight = null; - else weight = parseFloat(weight).toFixed(0); + if (aux) { + weight = ((parseFloat(weight)/aux) * 100).toFixed(0) + "%"; // weight percentage + } + else weight = null; // it's indifferent which weight has factor, we won't show it return { data: { source: source.id, From 94e42f339ca5a1a466b2564ec0e16c02cf4ef864 Mon Sep 17 00:00:00 2001 From: AlexV Date: Fri, 10 Jan 2020 13:17:16 +0100 Subject: [PATCH 2/2] Change version tag and refresh documentation --- build.gradle | 2 +- docs/asciidoc/index.adoc | 2 +- docs/asciidoc/index.html | 156 +++++++++++++++++++-------------------- sonar-project.properties | 2 +- 4 files changed, 81 insertions(+), 81 deletions(-) diff --git a/build.gradle b/build.gradle index 6fe61805..cbd40923 100644 --- a/build.gradle +++ b/build.gradle @@ -26,7 +26,7 @@ apply plugin: 'jacoco' apply plugin: 'org.asciidoctor.convert' group = 'com.upc.gessi.qrapids' -version = '1.1' +version = '1.1.1' sourceCompatibility = 1.8 war { diff --git a/docs/asciidoc/index.adoc b/docs/asciidoc/index.adoc index 0d366f2a..d434e4c0 100644 --- a/docs/asciidoc/index.adoc +++ b/docs/asciidoc/index.adoc @@ -1,5 +1,5 @@ = Q-Rapids Dashboard API REST Documentation -v1.1, {docdate} +v1.1.1, {docdate} :toc: left :sectnums: diff --git a/docs/asciidoc/index.html b/docs/asciidoc/index.html index 5d14ade9..98d19659 100644 --- a/docs/asciidoc/index.html +++ b/docs/asciidoc/index.html @@ -5,7 +5,7 @@ - + Q-Rapids Dashboard API REST Documentation