Merge pull request #116 from 67P/bugfix/vetoed_in_type_graph
Don't include vetoed contributions in graph
This commit was merged in pull request #116.
This commit is contained in:
@@ -20,9 +20,11 @@ export default Component.extend({
|
|||||||
|
|
||||||
chartData: computed('contributions', function() {
|
chartData: computed('contributions', function() {
|
||||||
let kredits = this.contributions
|
let kredits = this.contributions
|
||||||
|
.filterBy('vetoed', false)
|
||||||
.map(c => {
|
.map(c => {
|
||||||
return { kind: c.kind, amount: c.amount }
|
return { kind: c.kind, amount: c.amount }
|
||||||
}).reduce(function (kinds, c) {
|
})
|
||||||
|
.reduce(function (kinds, c) {
|
||||||
if (c.kind in kinds) {
|
if (c.kind in kinds) {
|
||||||
kinds[c.kind] = kinds[c.kind] + c.amount
|
kinds[c.kind] = kinds[c.kind] + c.amount
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -4,22 +4,22 @@ import { setupTest } from 'ember-qunit';
|
|||||||
module('Unit | Component | chart-contributions-by-type', function(hooks) {
|
module('Unit | Component | chart-contributions-by-type', function(hooks) {
|
||||||
setupTest(hooks);
|
setupTest(hooks);
|
||||||
|
|
||||||
let proposals = [
|
let contributions = [
|
||||||
{ kind: 'dev', amount: 500 },
|
{ kind: 'dev' , amount: 500 , vetoed: true },
|
||||||
{ kind: 'dev', amount: 1500 },
|
{ kind: 'dev' , amount: 1500 , vetoed: false },
|
||||||
{ kind: 'ops', amount: 1500 },
|
{ kind: 'ops' , amount: 1500 , vetoed: false },
|
||||||
{ kind: 'design', amount: 5000 },
|
{ kind: 'design' , amount: 5000 , vetoed: false },
|
||||||
{ kind: 'ops', amount: 1500 },
|
{ kind: 'ops' , amount: 1500 , vetoed: false },
|
||||||
{ kind: 'dev', amount: 5000 },
|
{ kind: 'dev' , amount: 5000 , vetoed: false },
|
||||||
{ kind: 'community', amount: 5000 },
|
{ kind: 'community' , amount: 5000 , vetoed: false },
|
||||||
{ kind: 'docs', amount: 500 },
|
{ kind: 'docs' , amount: 500 , vetoed: true },
|
||||||
{ kind: 'docs', amount: 500 },
|
{ kind: 'docs' , amount: 500 , vetoed: false },
|
||||||
{ kind: 'docs', amount: 500 },
|
{ kind: 'docs' , amount: 500 , vetoed: false }
|
||||||
];
|
];
|
||||||
|
|
||||||
test('#chartData', function(assert) {
|
test('#chartData', function(assert) {
|
||||||
let component = this.owner.factoryFor('component:chart-contributions-by-type').create();
|
let component = this.owner.factoryFor('component:chart-contributions-by-type').create();
|
||||||
component.set('contributions', proposals);
|
component.set('contributions', contributions);
|
||||||
|
|
||||||
let data = component.get('chartData');
|
let data = component.get('chartData');
|
||||||
|
|
||||||
@@ -30,7 +30,7 @@ module('Unit | Component | chart-contributions-by-type', function(hooks) {
|
|||||||
);
|
);
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
data.datasets[0].data,
|
data.datasets[0].data,
|
||||||
[5000, 5000, 7000, 3000, 1500],
|
[5000, 5000, 6500, 3000, 1000],
|
||||||
'returns the correct kredit sums'
|
'returns the correct kredit sums'
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user