Merge pull request #11 from 67P/feature/contributors_list
Contributor list improvements
This commit was merged in pull request #11.
This commit is contained in:
@@ -43,8 +43,14 @@ export default Ember.Controller.extend({
|
||||
proposalsClosedSorted: Ember.computed.sort('proposalsClosed', 'proposalsSorting'),
|
||||
proposalsOpenSorted: Ember.computed.sort('proposalsOpen', 'proposalsSorting'),
|
||||
|
||||
contributorsWithKredits: function() {
|
||||
return this.get('model.contributors').filter(c => {
|
||||
return c.get('kredits') !== 0;
|
||||
});
|
||||
}.property('model.contributors.[]'),
|
||||
|
||||
contributorsSorting: ['kredits:desc'],
|
||||
contributorsSorted: Ember.computed.sort('model.contributors', 'contributorsSorting'),
|
||||
contributorsSorted: Ember.computed.sort('contributorsWithKredits', 'contributorsSorting'),
|
||||
|
||||
watchContractEvents: function() {
|
||||
let events = this.get('kredits.kreditsContract')
|
||||
|
||||
@@ -10,7 +10,6 @@ export default Ember.Route.extend({
|
||||
return Ember.RSVP.hash({
|
||||
contributors: kredits.getContributors(),
|
||||
totalSupply: kredits.getValueFromContract('tokenContract', 'totalSupply'),
|
||||
contributorsCount: kredits.getValueFromContract('kreditsContract', 'contributorsCount'),
|
||||
proposals: kredits.getProposals()
|
||||
});
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
<p class="stats">
|
||||
<span class="number">{{model.totalSupply}}</span> kredits issued and distributed among
|
||||
<span class="number">{{model.contributorsCount}}</span> contributors.
|
||||
<span class="number">{{contributorsWithKredits.length}}</span> contributors.
|
||||
</p>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
@@ -1,11 +1,38 @@
|
||||
// import { moduleFor, test } from 'ember-qunit';
|
||||
//
|
||||
// moduleFor('controller:index', 'Unit | Controller | index');
|
||||
import Ember from 'ember';
|
||||
import Contributor from 'kredits-web/models/contributor';
|
||||
import { moduleFor, test } from 'ember-qunit';
|
||||
|
||||
// let addFixtures = function(controller) {
|
||||
// controller.set('model', { contributors: [
|
||||
// { github_username: "neo", github_uid: "318", kredits: 10000 },
|
||||
// { github_username: "morpheus", github_uid: "843", kredits: 15000 },
|
||||
// { github_username: "mouse", github_uid: "842", kredits: 5000 },
|
||||
// ]});
|
||||
// };
|
||||
const {
|
||||
isPresent,
|
||||
isEmpty
|
||||
} = Ember;
|
||||
|
||||
moduleFor('controller:index', 'Unit | Controller | index', {
|
||||
needs: ['service:ipfs', 'service:kredits']
|
||||
});
|
||||
|
||||
let addFixtures = function(controller) {
|
||||
controller.set('model', {
|
||||
contributors: [],
|
||||
proposals: []
|
||||
});
|
||||
|
||||
[
|
||||
{ github_username: "neo", github_uid: "318", kredits: 10000 },
|
||||
{ github_username: "morpheus", github_uid: "843", kredits: 15000 },
|
||||
{ github_username: "trinity", github_uid: "123", kredits: 5000 },
|
||||
{ github_username: "mouse", github_uid: "696", kredits: 0 }
|
||||
].forEach(fixture => {
|
||||
controller.get('model.contributors').push(Contributor.create(fixture));
|
||||
});
|
||||
};
|
||||
|
||||
test('doesn\'t contain people with 0 kredits', function(assert) {
|
||||
let controller = this.subject();
|
||||
addFixtures(controller);
|
||||
|
||||
let contributorsSorted = controller.get('contributorsSorted');
|
||||
|
||||
assert.ok(isPresent(contributorsSorted.findBy('github_username', 'neo')));
|
||||
assert.ok(isEmpty(contributorsSorted.findBy('github_username', 'mouse')));
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user