export function getMeasures (componentKey, metrics) {
- const url = baseUrl + '/api/resources/index';
- const data = { resource: componentKey, metrics: metrics.join(',') };
- return getJSON(url, data).then(r => {
- const msr = r[0].msr || [];
- const measures = {};
- msr.forEach(measure => {
- measures[measure.key] = measure.val || measure.data;
- });
- return measures;
- });
-}
-
-
-export function getMeasuresAndVariations (componentKey, metrics) {
- const url = baseUrl + '/api/resources/index';
- const data = { resource: componentKey, metrics: metrics.join(','), includetrends: 'true' };
- return getJSON(url, data).then(r => {
- const msr = r[0].msr || [];
- const measures = {};
- msr.forEach(measure => {
- measures[measure.key] = {
- value: measure.val != null ? measure.val : measure.data,
- var1: measure.var1,
- var2: measure.var2,
- var3: measure.var3
- };
- });
- return measures;
- });
+ const url = baseUrl + '/api/measures/component';
+ const data = { componentKey, metricKeys: metrics.join(',') };
+ return getJSON(url, data).then(r => r.component.measures);
}
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
+import _ from 'underscore';
import d3 from 'd3';
import React from 'react';
-import { getMeasuresAndVariations } from '../../../api/measures';
+import { getMeasures } from '../../../api/measures';
import { DomainTimeline } from '../components/domain-timeline';
import { DomainTreemap } from '../components/domain-treemap';
import { DomainBubbleChart } from '../components/domain-bubble-chart';
componentDidMount() {
this.requestMeasures().then(r => {
- let measures = this.getMeasuresValues(r, 'value');
- let leak = this.getMeasuresValues(r, 'var' + this.props.leakPeriodIndex);
+ let measures = this.getMeasuresValues(r);
+ let leak = this.getMeasuresValues(r, Number(this.props.leakPeriodIndex));
this.setState({
ready: true,
measures,
});
},
- getMeasuresValues (measures, fieldKey) {
+ getMeasuresValues (measures, period) {
let values = {};
- Object.keys(measures).forEach(measureKey => {
- values[measureKey] = measures[measureKey][fieldKey];
+ measures.forEach(measure => {
+ const container = period ? _.findWhere(measure.periods, { index: period }) : measure;
+ if (container) {
+ values[measure.metric] = container.value;
+ }
});
return values;
},
},
requestMeasures () {
- return getMeasuresAndVariations(this.props.component.key, this.getMetricsForDomain());
+ return getMeasures(this.props.component.key, this.getMetricsForDomain());
},
renderLoading () {
import d3 from 'd3';
import React from 'react';
-import { getMeasuresAndVariations } from '../../../api/measures';
+import { getMeasures } from '../../../api/measures';
import { DetailedMeasure } from '../components/detailed-measure';
import { DomainTimeline } from '../components/domain-timeline';
import { DomainTreemap } from '../components/domain-treemap';
this.requestIssues(),
this.requestAssignees()
]).then(responses => {
- let measures = this.getMeasuresValues(responses[0], 'value');
- let leak = this.getMeasuresValues(responses[0], 'var' + this.props.leakPeriodIndex);
+ let measures = this.getMeasuresValues(responses[0]);
+ let leak = this.getMeasuresValues(responses[0], Number(this.props.leakPeriodIndex));
let tags = responses[1].facet;
let assignees = extractAssignees(responses[2].facet, responses[2].response);
this.setState({ ready: true, measures, leak, tags, assignees });
});
},
- getMeasuresValues (measures, fieldKey) {
+ getMeasuresValues (measures, period) {
let values = {};
- Object.keys(measures).forEach(measureKey => {
- values[measureKey] = measures[measureKey][fieldKey];
+ measures.forEach(measure => {
+ const container = period ? _.findWhere(measure.periods, { index: period }) : measure;
+ if (container) {
+ values[measure.metric] = container.value;
+ }
});
return values;
},
},
requestMeasures () {
- return getMeasuresAndVariations(this.props.component.key, this.getMetricsForDomain());
+ return getMeasures(this.props.component.key, this.getMetricsForDomain());
},
getFacet (facets, facetKey) {
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
+import _ from 'underscore';
import d3 from 'd3';
import React from 'react';
-import { getMeasuresAndVariations } from '../../../api/measures';
+import { getMeasures } from '../../../api/measures';
import { DetailedMeasure } from '../components/detailed-measure';
import { DomainTimeline } from '../components/domain-timeline';
import { DomainTreemap } from '../components/domain-treemap';
componentDidMount() {
this.requestMeasures().then(r => {
- let measures = this.getMeasuresValues(r, 'value');
- let leak = this.getMeasuresValues(r, 'var' + this.props.leakPeriodIndex);
+ let measures = this.getMeasuresValues(r);
+ let leak = this.getMeasuresValues(r, Number(this.props.leakPeriodIndex));
this.setState({ ready: true, measures, leak });
});
},
- getMeasuresValues (measures, fieldKey) {
+ getMeasuresValues (measures, period) {
let values = {};
- Object.keys(measures).forEach(measureKey => {
- values[measureKey] = measures[measureKey][fieldKey];
+ measures.forEach(measure => {
+ const container = period ? _.findWhere(measure.periods, { index: period }) : measure;
+ if (container) {
+ values[measure.metric] = container.value;
+ }
});
return values;
},
},
requestMeasures () {
- return getMeasuresAndVariations(this.props.component.key, this.getMetricsForDomain());
+ return getMeasures(this.props.component.key, this.getMetricsForDomain());
},
renderLoading () {
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
+import _ from 'underscore';
import React from 'react';
import { LanguageDistribution } from './../components/language-distribution';
import { ComplexityDistribution } from './../components/complexity-distribution';
import { NclocDistribution } from '../components/ncloc-distribution';
-import { getMeasuresAndVariations } from '../../../api/measures';
+import { getMeasures } from '../../../api/measures';
import { DetailedMeasure } from '../components/detailed-measure';
import { DomainTimeline } from '../components/domain-timeline';
import { getPeriodLabel, getPeriodDate } from './../helpers/periods';
componentDidMount() {
this.requestMeasures().then(r => {
- let measures = this.getMeasuresValues(r, 'value');
- let leak = this.getMeasuresValues(r, 'var' + this.props.leakPeriodIndex);
+ let measures = this.getMeasuresValues(r);
+ let leak = this.getMeasuresValues(r, Number(this.props.leakPeriodIndex));
this.setState({ ready: true, measures, leak });
});
},
- getMeasuresValues (measures, fieldKey) {
+ getMeasuresValues (measures, period) {
let values = {};
- Object.keys(measures).forEach(measureKey => {
- values[measureKey] = measures[measureKey][fieldKey];
+ measures.forEach(measure => {
+ const container = period ? _.findWhere(measure.periods, { index: period }) : measure;
+ if (container) {
+ values[measure.metric] = container.value;
+ }
});
return values;
},
},
requestMeasures () {
- return getMeasuresAndVariations(this.props.component.key, this.getMetricsForDomain());
+ return getMeasures(this.props.component.key, this.getMetricsForDomain());
},
renderLoading () {
if (distribution == null) {
return null;
}
- return <LanguageDistribution lines={this.state.measures['ncloc']} distribution={distribution}/>;
+ return <LanguageDistribution lines={Number(this.state.measures['ncloc'])} distribution={distribution}/>;
},
renderComplexityDistribution(distribution, props) {
import { GeneralStructure } from './structure';
import { CoverageSelectionMixin } from '../components/coverage-selection-mixin';
import { getPeriodLabel, getPeriodDate } from './../helpers/periods';
-import { getMeasuresAndVariations } from '../../../api/measures';
+import { getMeasures } from '../../../api/measures';
import { getIssuesCount } from '../../../api/issues';
import { getTimeMachineData } from '../../../api/time-machine';
this.requestIssuesAndDebt(),
this.requestLeakIssuesAndDebt()
]).then(responses => {
- let measures = this.getMeasuresValues(responses[0], 'value');
+ let measures = this.getMeasuresValues(responses[0]);
measures.issues = responses[1].issues;
measures.debt = responses[1].debt;
let leak;
if (this.state.leakPeriodDate) {
- leak = this.getMeasuresValues(responses[0], 'var' + this.props.leakPeriodIndex);
+ leak = this.getMeasuresValues(responses[0], Number(this.props.leakPeriodIndex));
leak.issues = responses[2].issues;
leak.debt = responses[2].debt;
}
},
requestMeasures () {
- return getMeasuresAndVariations(this.props.component.key, METRICS_LIST);
+ return getMeasures(this.props.component.key, METRICS_LIST);
},
- getMeasuresValues (measures, fieldKey) {
+ getMeasuresValues (measures, period) {
let values = {};
- Object.keys(measures).forEach(measureKey => {
- values[measureKey] = measures[measureKey][fieldKey];
+ measures.forEach(measure => {
+ const container = period ? _.findWhere(measure.periods, { index: period }) : measure;
+ if (container) {
+ values[measure.metric] = container.value;
+ }
});
return values;
},
}
return <Measure composite={true}>
<div style={{ width: 200 }}>
- <LanguageDistribution lines={this.props.measures['ncloc']}
+ <LanguageDistribution lines={Number(this.props.measures['ncloc'])}
distribution={this.props.measures['ncloc_language_distribution']}/>
</div>
</Measure>;