Skip to content

Commit 7c5629e

Browse files
committed
Added Potential Fix to loading error
1 parent 4b490ab commit 7c5629e

File tree

2 files changed

+34
-24
lines changed

2 files changed

+34
-24
lines changed

src/components/org/OrgContributors.vue

Lines changed: 30 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -49,33 +49,41 @@ export default {
4949
5050
let topContributors = [];
5151
const orgRepos = await this.getRepos();
52-
try {
53-
for (let i = 0; i < orgRepos.length; i++) {
54-
const contributors = await this.getContributors(orgRepos[i].name);
55-
contributors.forEach(function(contributor) {
56-
if (!topContributors.hasOwnProperty(contributor.author.login)) {
57-
topContributors[contributor.author.login] = {
58-
name: contributor.author.login,
59-
total: contributor.total,
60-
weeks: contributor.weeks,
61-
avatar: contributor.author.avatar_url
62-
};
63-
} else {
52+
for (let i = 0; i < orgRepos.length; i++) {
53+
const contributors = await this.getContributors(orgRepos[i].name);
54+
for(let j = 0; j < contributors.length; j++) {
55+
let contributor = contributors[j];
56+
if (!topContributors.hasOwnProperty(contributor.author.login)) {
57+
topContributors[contributor.author.login] = {
58+
name: contributor.author.login,
59+
total: contributor.total,
60+
weeks: contributor.weeks,
61+
avatar: contributor.author.avatar_url
62+
};
63+
} else {
64+
try {
6465
topContributors[contributor.author.login].total +=
6566
contributor.total;
66-
for (let j = 0; j < contributor.weeks.length; j++) {
67-
topContributors[contributor.author.login].weeks[j].c +=
68-
contributor.weeks[j].c;
69-
topContributors[contributor.author.login].weeks[j].a +=
70-
contributor.weeks[j].a;
71-
topContributors[contributor.author.login].weeks[j].d +=
72-
contributor.weeks[j].d;
67+
for (let k = 0; k < contributor.weeks.length; k++) {
68+
if(topContributors[contributor.author.login].weeks.length <= k)
69+
topContributors[contributor.author.login].weeks.push({
70+
w: contributor.weeks[k].w,
71+
a: 0,
72+
d: 0,
73+
c: 0
74+
})
75+
topContributors[contributor.author.login].weeks[k].c +=
76+
contributor.weeks[k].c;
77+
topContributors[contributor.author.login].weeks[k].a +=
78+
contributor.weeks[k].a;
79+
topContributors[contributor.author.login].weeks[k].d +=
80+
contributor.weeks[k].d;
7381
}
82+
} catch (err) {
83+
console.log(err)
7484
}
75-
});
85+
}
7686
}
77-
} catch (err) {
78-
console.log(err);
7987
}
8088
8189
//store this

src/store.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,8 @@ export default new Vuex.Store({
100100
let data = context.state.orgCommits[org];
101101
data.sort(function(a, b) {
102102
let sum1 = 0, sum2 = 0;
103-
for(let i = a.weeks.length - 1; i >= a.weeks.length - 4 && i >= 0; i--) {
103+
let len = Math.min(a.weeks.length, b.weeks.length);
104+
for(let i = len - 1; i >= len - 4 && i >= 0; i--) {
104105
sum1 += a.weeks[i].c;
105106
sum2 += b.weeks[i].c;
106107
}
@@ -117,7 +118,8 @@ export default new Vuex.Store({
117118
let data = context.state.orgCommits[org];
118119
data.sort(function(a, b) {
119120
let sum1 = 0, sum2 = 0;
120-
for(let i = a.weeks.length - 1; i >= a.weeks.length - 52 && i >= 0; i--) {
121+
let len = Math.min(a.weeks.length, b.weeks.length);
122+
for(let i = len - 1; i >= len - 52 && i >= 0; i--) {
121123
sum1 += a.weeks[i].c;
122124
sum2 += b.weeks[i].c;
123125
}

0 commit comments

Comments
 (0)