Skip to content

Commit 67b20a3

Browse files
committed
Added Potential Fix to loading error
1 parent 4b490ab commit 67b20a3

File tree

3 files changed

+39
-26
lines changed

3 files changed

+39
-26
lines changed

src/assets/badges/special/specialBadges.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,13 @@ export default class SpecialBadges {
2121
if (topCommits[0].name === name) {
2222
badges.push(topCommitsBadge);
2323
}
24+
2425
if (topWeekCommits[0].name === name) {
25-
if(topWeekCommits[0].weeks[0].c > 0) {
26+
if(topWeekCommits[0].weeks[topWeekCommits[0].weeks.length - 1].c > 0) {
2627
badges.push(topWeekCommitsBadge);
2728
}
2829
}
30+
2931
if (topMonthCommits[0].name === name) {
3032
let actuallyHasCommited = false;
3133
for(let week in topMonthCommits[0].weeks)
@@ -40,6 +42,7 @@ export default class SpecialBadges {
4042
if(actuallyHasCommited)
4143
badges.push(topMonthCommitsBadge);
4244
}
45+
4346
if (topYearCommits[0].name === name) {
4447
let actuallyHasCommited = false;
4548
for(let week in topYearCommits[0].weeks)

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: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ export default new Vuex.Store({
8787
{
8888
let data = context.state.orgCommits[org];
8989
data.sort(function(a, b) {
90-
return b.weeks.reverse()[0].c - a.weeks.reverse()[0].c;
90+
return b.weeks[b.weeks.length - 1].c - a.weeks[a.weeks.length - 1].c;
9191
});
9292
topWeekCommits[org] = data;
9393
}
@@ -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)