volunteer-contributions-fetch 2.3.0 → 2.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/bugzilla.js +3 -1
- package/lib/bugzilla.test.js +42 -7
- package/package.json +1 -1
package/lib/bugzilla.js
CHANGED
|
@@ -71,7 +71,9 @@ async function gather({ bugzilla }, existingContributions = []) {
|
|
|
71
71
|
contributions = contributions.concat(comments);
|
|
72
72
|
}
|
|
73
73
|
|
|
74
|
-
return contributions
|
|
74
|
+
return contributions.filter((contribution) => {
|
|
75
|
+
return contribution.createdAt > new Date(latest.createdAt);
|
|
76
|
+
});
|
|
75
77
|
}
|
|
76
78
|
|
|
77
79
|
async function* bugPageGenerator(bugzilla, stopDate) {
|
package/lib/bugzilla.test.js
CHANGED
|
@@ -19,7 +19,7 @@ test.beforeEach((t) => {
|
|
|
19
19
|
|
|
20
20
|
const firstBugsPage = {
|
|
21
21
|
bugs: new Array(500).fill(0).map(() => ({
|
|
22
|
-
created_at: new Date('
|
|
22
|
+
created_at: new Date('2022-04-13'),
|
|
23
23
|
summary: 'Summary',
|
|
24
24
|
// This would be the bug ID which would be different, but enough for testing purposes
|
|
25
25
|
id: 1,
|
|
@@ -28,7 +28,7 @@ test.beforeEach((t) => {
|
|
|
28
28
|
|
|
29
29
|
const secondBugsPage = {
|
|
30
30
|
bugs: [{
|
|
31
|
-
created_at: new Date('
|
|
31
|
+
created_at: new Date('2022-04-13'),
|
|
32
32
|
summary: 'SecondSummary',
|
|
33
33
|
id: 1,
|
|
34
34
|
}]
|
|
@@ -39,17 +39,17 @@ test.beforeEach((t) => {
|
|
|
39
39
|
// This would be the bug ID which would be different, but enough for testing purposes
|
|
40
40
|
1: {
|
|
41
41
|
comments: [{
|
|
42
|
-
creation_time: new Date('
|
|
42
|
+
creation_time: new Date('2022-04-13'),
|
|
43
43
|
creator: 'user',
|
|
44
44
|
bug_id: 1,
|
|
45
45
|
count: 0,
|
|
46
46
|
}, {
|
|
47
|
-
creation_time: new Date('
|
|
47
|
+
creation_time: new Date('2022-04-13'),
|
|
48
48
|
creator: 'user',
|
|
49
49
|
bug_id: 1,
|
|
50
50
|
count: 1,
|
|
51
51
|
}, {
|
|
52
|
-
creation_time: new Date('
|
|
52
|
+
creation_time: new Date('2022-04-13'),
|
|
53
53
|
creator: 'WILL_BE_FILTERED_OUT',
|
|
54
54
|
bug_id: 1,
|
|
55
55
|
count: 2,
|
|
@@ -137,14 +137,14 @@ test.serial('should format', async (t) => {
|
|
|
137
137
|
const contributions = await bugzilla.gather(config);
|
|
138
138
|
|
|
139
139
|
t.deepEqual(contributions[0], {
|
|
140
|
-
createdAt: new Date('
|
|
140
|
+
createdAt: new Date('2022-04-13'),
|
|
141
141
|
description: 'SecondSummary',
|
|
142
142
|
link: 'https://bugzilla.mozilla.org/show_bug.cgi?id=1#c0',
|
|
143
143
|
type: 'Created a Bug Report',
|
|
144
144
|
source: 'bugzilla-created',
|
|
145
145
|
});
|
|
146
146
|
t.deepEqual(contributions[1], {
|
|
147
|
-
createdAt: new Date('
|
|
147
|
+
createdAt: new Date('2022-04-13'),
|
|
148
148
|
description: 'SecondSummary',
|
|
149
149
|
link: 'https://bugzilla.mozilla.org/show_bug.cgi?id=1#c1',
|
|
150
150
|
type: 'Commented on a Bug Report',
|
|
@@ -168,3 +168,38 @@ test.serial('should format with custom types', async (t) => {
|
|
|
168
168
|
t.is(contributions[0].type, specificTypeConfig.bugzilla.types.createdType);
|
|
169
169
|
t.is(contributions[1].type, specificTypeConfig.bugzilla.types.commentedType);
|
|
170
170
|
});
|
|
171
|
+
|
|
172
|
+
test.serial('should ignore comments older than stopDate', async (t) => {
|
|
173
|
+
const bugsPage = {
|
|
174
|
+
bugs: [{
|
|
175
|
+
created_at: new Date('2022-04-13'),
|
|
176
|
+
summary: 'Summary',
|
|
177
|
+
id: 1,
|
|
178
|
+
}]
|
|
179
|
+
};
|
|
180
|
+
|
|
181
|
+
const oldComments = {
|
|
182
|
+
bugs: {
|
|
183
|
+
1: {
|
|
184
|
+
comments: [{
|
|
185
|
+
creation_time: new Date('1999-04-13'),
|
|
186
|
+
creator: 'user',
|
|
187
|
+
bug_id: 1,
|
|
188
|
+
count: 0,
|
|
189
|
+
}, {
|
|
190
|
+
creation_time: new Date('1999-04-13'),
|
|
191
|
+
creator: 'user',
|
|
192
|
+
bug_id: 1,
|
|
193
|
+
count: 1,
|
|
194
|
+
}],
|
|
195
|
+
},
|
|
196
|
+
},
|
|
197
|
+
};
|
|
198
|
+
|
|
199
|
+
axios.request.onCall(0)
|
|
200
|
+
.resolves({ data: bugsPage });
|
|
201
|
+
axios.request.onCall(1).resolves({ data: oldComments });
|
|
202
|
+
|
|
203
|
+
const contributions = await bugzilla.gather(config);
|
|
204
|
+
t.is(contributions.length, 0);
|
|
205
|
+
});
|