Commit 4824f79c authored by schrieveslaach's avatar schrieveslaach

sonarqube-plugin: improve chart rendering

parent 41a7a014
Pipeline #37939291 passed with stages
in 40 minutes and 29 seconds
......@@ -106,7 +106,7 @@ export function findNlpPipelinePerformanceDataSets(project, dataSetConfiguration
// Loads for each dataSet the time series of F-measures
dataSets.forEach(dataSet => {
promises.push(findBestPerformingPipelineFMeasure(project, dataSet.annotationClassName)
.then((fMeasureHistoryData) => {
.then(fMeasureHistoryData => {
dataSet.data = fMeasureHistoryData;
return dataSet;
}).catch(err => {
......@@ -114,40 +114,42 @@ export function findNlpPipelinePerformanceDataSets(project, dataSetConfiguration
}));
});
return Promise.all(promises).then(values => values.filter(data => data !== undefined));
return Promise.all(promises)
.then(values => values.filter(data => data !== undefined));
});
}
function findBestPerformingPipelineFMeasure(project, annotation) {
return getJSON(`/api/measures/search_history?component=${project.key}&metrics=${annotation}`).then(response => {
if (response.errors !== undefined) {
return [];
}
return getJSON(`/api/measures/search_history?component=${project.key}&metrics=${annotation}`)
.then(response => {
if (response.errors !== undefined) {
return [];
}
const fMeasureHistory = response.measures[0].history;
const fMeasureHistory = response.measures[0].history;
let fMeasureHistoryChartJsData = [];
for (let i = 0; i < fMeasureHistory.length; i++) {
let value = fMeasureHistory[i].value;
let fMeasureHistoryChartJsData = [];
for (let i = 0; i < fMeasureHistory.length; i++) {
let value = fMeasureHistory[i].value;
if (value === undefined) {
continue;
}
if (value === undefined) {
continue;
}
let data = JSON.parse(value);
let data = JSON.parse(value);
fMeasureHistoryChartJsData.push({
x: fMeasureHistory[i].date,
// TODO currently returns only data for best-performing NLP pipeline
y: data[0]["f-measure"],
});
}
fMeasureHistoryChartJsData.push({
x: fMeasureHistory[i].date,
// TODO currently returns only data for best-performing NLP pipeline
y: data[0]["f-measure"],
});
}
//History date format: YYYY-MM-DDTHH:mm:ssZ
fMeasureHistoryChartJsData.sort((a, b) => new Date(b.x) - new Date(a.x));
//History date format: YYYY-MM-DDTHH:mm:ssZ
fMeasureHistoryChartJsData.sort((a, b) => new Date(b.x) - new Date(a.x));
return fMeasureHistoryChartJsData;
});
return fMeasureHistoryChartJsData;
});
}
export function findNerHeatmapData(project) {
......
......@@ -103,16 +103,17 @@ export default class PerformanceGraph extends React.PureComponent {
datasets: [newDataSet]
});
}).then(() => {
findNlpPipelinePerformanceDataSets(this.props.project).then((performanceDataSets) => {
const oldDataSet = this.state.datasets[0];
const newDataSets = [{
...oldDataSet
}].concat(performanceDataSets);
findNlpPipelinePerformanceDataSets(this.props.project)
.then(performanceDataSets => {
const oldDataSet = this.state.datasets[0];
const newDataSets = [{
...oldDataSet
}].concat(performanceDataSets.filter(dataSet => dataSet.data.length > 0));
this.setState({
datasets: newDataSets
this.setState({
datasets: newDataSets
});
});
});
})
};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment