Process contribution data before loading models

This commit is contained in:
2020-05-28 13:44:32 +02:00
parent e7c9620bbe
commit 69141a31c4
10 changed files with 501 additions and 34 deletions
File diff suppressed because one or more lines are too long
+13 -11
View File
@@ -1,23 +1,25 @@
import Model from 'kredits-web/models/contribution';
import contributors from '../../tests/fixtures/contributors';
import processContributionData from 'kredits-web/utils/process-contribution-data';
const items = [];
const data = [
{ id: 1, contributorId: 1, confirmedAtBlock: 1000, claimed: false, vetoed: false, amount: 1500, kind: 'dev' },
{ id: 2, contributorId: 1, confirmedAtBlock: 1000, claimed: false, vetoed: false, amount: 5000, kind: 'ops' },
{ id: 3, contributorId: 2, confirmedAtBlock: 1000, claimed: false, vetoed: false, amount: 1500, kind: 'ops' },
{ id: 4, contributorId: 2, confirmedAtBlock: 1000, claimed: false, vetoed: false, amount: 1500, kind: 'docs' },
{ id: 5, contributorId: 1, confirmedAtBlock: 1000, claimed: false, vetoed: false, amount: 5000, kind: 'design' },
{ id: 6, contributorId: 1, confirmedAtBlock: 1000, claimed: false, vetoed: true, amount: 500, kind: 'dev' },
{ id: 7, contributorId: 3, confirmedAtBlock: 2000, claimed: false, vetoed: false, amount: 5000, kind: 'dev' },
{ id: 8, contributorId: 1, confirmedAtBlock: 2000, claimed: false, vetoed: false, amount: 1500, kind: 'community' },
{ id: 9, contributorId: 3, confirmedAtBlock: 2000, claimed: false, vetoed: true, amount: 1500, kind: 'docs' },
{ id: 1, contributorId: 1, confirmedAt: 1000, claimed: false, vetoed: false, amount: 1500, kind: 'dev' },
{ id: 2, contributorId: 1, confirmedAt: 1000, claimed: false, vetoed: false, amount: 5000, kind: 'ops' },
{ id: 3, contributorId: 2, confirmedAt: 1000, claimed: false, vetoed: false, amount: 1500, kind: 'ops' },
{ id: 4, contributorId: 2, confirmedAt: 1000, claimed: false, vetoed: false, amount: 1500, kind: 'docs' },
{ id: 5, contributorId: 1, confirmedAt: 1000, claimed: false, vetoed: false, amount: 5000, kind: 'design' },
{ id: 6, contributorId: 1, confirmedAt: 1000, claimed: false, vetoed: true, amount: 500, kind: 'dev' },
{ id: 7, contributorId: 3, confirmedAt: 2000, claimed: false, vetoed: false, amount: 5000, kind: 'dev' },
{ id: 8, contributorId: 1, confirmedAt: 2000, claimed: false, vetoed: false, amount: 1500, kind: 'community' },
{ id: 9, contributorId: 3, confirmedAt: 2000, claimed: false, vetoed: true, amount: 1500, kind: 'docs' },
];
data.forEach(attrs => {
attrs.contributor = contributors.findBy('id', attrs.contributorId.toString());
items.push(Model.create(attrs))
const c = Model.create(processContributionData(attrs));
c.set('contributor', contributors.findBy('id', attrs.contributorId.toString()));
items.push(c);
});
export default items;
+5 -1
View File
@@ -1,4 +1,5 @@
import Contributor from 'kredits-web/models/contributor';
import processContributorData from 'kredits-web/utils/process-contributor-data';
const contributors = [];
@@ -8,6 +9,9 @@ const data = [
{ id: '3', name: 'Manuel', totalKreditsEarned: 0, github_uid: 54812 }
];
data.forEach(attrs => contributors.push(Contributor.create(attrs)));
data.forEach(attrs => {
const c = Contributor.create(processContributorData(attrs));
contributors.push(c);
});
export default contributors;