volunteer-contributions-fetch 2.3.2 → 2.3.3

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.
@@ -40,10 +40,7 @@ async function gather({ communityPortal }) {
40
40
  const document = await getCommunityPortalDocument(profileUrl);
41
41
  const events = await processEvents(communityPortal, document);
42
42
  const campaigns = await processCampaigns(communityPortal, document);
43
- const contributions = [
44
- ...events,
45
- ...campaigns,
46
- ];
43
+ const contributions = [...events, ...campaigns];
47
44
 
48
45
  debug('Finished gathering contributions');
49
46
  return contributions;
@@ -53,9 +50,8 @@ async function processEvents(communityPortal, document) {
53
50
  debug('Getting events from Community Portal');
54
51
  const allEventNodes = document.querySelectorAll('.profile__event');
55
52
 
56
- const allEvents = Array.from(
57
- allEventNodes,
58
- (entity) => formatEvent(communityPortal.participationType, entity)
53
+ const allEvents = Array.from(allEventNodes, (entity) =>
54
+ formatEvent(communityPortal.participationType, entity)
59
55
  )
60
56
  .sort((a, b) => b.createdAt - a.createdAt)
61
57
  .filter((event) => event.createdAt < new Date());
@@ -66,9 +62,8 @@ async function processCampaigns(communityPortal, document) {
66
62
  debug('Getting campaigns from Community Portal');
67
63
  const allCampaignNodes = document.querySelectorAll('.profile__campaign');
68
64
 
69
- return Array.from(
70
- allCampaignNodes,
71
- (entity) => formatCampaign(communityPortal.campaignType, entity)
65
+ return Array.from(allCampaignNodes, (entity) =>
66
+ formatCampaign(communityPortal.campaignType, entity)
72
67
  )
73
68
  .sort((a, b) => b.createdAt - a.createdAt)
74
69
  .filter((campaign) => campaign.createdAt < new Date());
@@ -82,8 +77,14 @@ async function getCommunityPortalDocument(url) {
82
77
 
83
78
  function formatEvent(type, entity) {
84
79
  return {
85
- createdAt: new Date(entity.querySelector('.profile__event-time').textContent.replace(/[\n\t∙]/g, '')),
86
- description: entity.querySelector('.profile__event-title').textContent.replace(/[\n\t]/g, ''),
80
+ createdAt: new Date(
81
+ entity
82
+ .querySelector('.profile__event-time')
83
+ .textContent.replace(/[\n\t∙]/g, '')
84
+ ),
85
+ description: entity
86
+ .querySelector('.profile__event-title')
87
+ .textContent.replace(/[\n\t]/g, ''),
87
88
  link: entity.getAttribute('href'),
88
89
  type: type || TYPE_PARTICIPATION,
89
90
  source: EVENTS_CATEGORY,
@@ -91,10 +92,15 @@ function formatEvent(type, entity) {
91
92
  }
92
93
 
93
94
  function formatCampaign(type, entity) {
94
- const dateValue = entity.querySelector('.profile__campaign-dates').textContent.replace(/[\n\t∙]/g, '').replace(/\s*-\s*[a-zA-Z]+\s\d{2}/g, '');
95
+ const dateValue = entity
96
+ .querySelector('.profile__campaign-dates')
97
+ .textContent.replace(/[\n\t∙]/g, '')
98
+ .replace(/\s*-\s*[a-zA-Z]+\s\d{2}/g, '');
95
99
  return {
96
100
  createdAt: new Date(dateValue),
97
- description: entity.querySelector('.profile__campaign-title').textContent.replace(/[\n\t]/g, ''),
101
+ description: entity
102
+ .querySelector('.profile__campaign-title')
103
+ .textContent.replace(/[\n\t]/g, ''),
98
104
  link: entity.getAttribute('href'),
99
105
  type: type || TYPE_CAMPAIGN,
100
106
  source: CAMPAIGNS_CATEGORY,
@@ -10,7 +10,7 @@ const config = {
10
10
  enabled: true,
11
11
  baseUrl: 'https://community.mozilla.org',
12
12
  username: 'user',
13
- }
13
+ },
14
14
  };
15
15
 
16
16
  test.beforeEach((t) => {
@@ -65,16 +65,19 @@ test.serial('should fetch even though sections are empty', async (t) => {
65
65
  t.is(contributions.length, 0);
66
66
  });
67
67
 
68
- test.serial('should only fetch events and campaigns that are not in the future', async (t) => {
69
- JSDOM.fromURL.resolves(fixtures.futureData);
70
-
71
- const contributions = await communityPortal.gather(config);
72
- t.is(contributions.length, 2);
73
- t.deepEqual(contributions[0].createdAt, new Date('2022-08-11'));
74
- t.is(contributions[0].description, 'PastEvent');
75
- t.deepEqual(contributions[1].createdAt, new Date('2022-02-01'));
76
- t.is(contributions[1].description, 'PastCampaign');
77
- });
68
+ test.serial(
69
+ 'should only fetch events and campaigns that are not in the future',
70
+ async (t) => {
71
+ JSDOM.fromURL.resolves(fixtures.futureData);
72
+
73
+ const contributions = await communityPortal.gather(config);
74
+ t.is(contributions.length, 2);
75
+ t.deepEqual(contributions[0].createdAt, new Date('2022-08-11'));
76
+ t.is(contributions[0].description, 'PastEvent');
77
+ t.deepEqual(contributions[1].createdAt, new Date('2022-02-01'));
78
+ t.is(contributions[1].description, 'PastCampaign');
79
+ }
80
+ );
78
81
 
79
82
  test.serial('should not fetch if disabled - by enable property', async (t) => {
80
83
  const specificTypeConfig = {
@@ -89,11 +92,14 @@ test.serial('should not fetch if disabled - by enable property', async (t) => {
89
92
  t.is(contributions.length, 0);
90
93
  });
91
94
 
92
- test.serial('should not fetch if disabled - by leaving off config value', async (t) => {
93
- const contributions = await communityPortal.gather({});
95
+ test.serial(
96
+ 'should not fetch if disabled - by leaving off config value',
97
+ async (t) => {
98
+ const contributions = await communityPortal.gather({});
94
99
 
95
- t.is(contributions.length, 0);
96
- });
100
+ t.is(contributions.length, 0);
101
+ }
102
+ );
97
103
 
98
104
  test.serial('should format', async (t) => {
99
105
  JSDOM.fromURL.resolves(fixtures.allData);
@@ -140,14 +146,20 @@ test.serial('should format with custom types', async (t) => {
140
146
  ...config.communityPortal,
141
147
  participationType: 'Event!',
142
148
  campaignType: 'Campaign!',
143
- }
149
+ },
144
150
  };
145
151
 
146
152
  const contributions = await communityPortal.gather(specificTypeConfig);
147
153
 
148
154
  // Event
149
- t.is(contributions[0].type, specificTypeConfig.communityPortal.participationType);
150
- t.is(contributions[1].type, specificTypeConfig.communityPortal.participationType);
155
+ t.is(
156
+ contributions[0].type,
157
+ specificTypeConfig.communityPortal.participationType
158
+ );
159
+ t.is(
160
+ contributions[1].type,
161
+ specificTypeConfig.communityPortal.participationType
162
+ );
151
163
  t.is(contributions[2].type, specificTypeConfig.communityPortal.campaignType);
152
164
  t.is(contributions[3].type, specificTypeConfig.communityPortal.campaignType);
153
165
  });
package/lib/discourse.js CHANGED
@@ -39,10 +39,7 @@ async function gather({ discourse }) {
39
39
 
40
40
  const topics = await processTopics(discourse);
41
41
  const posts = await processPosts(discourse);
42
- const contributions = [
43
- ...topics,
44
- ...posts,
45
- ];
42
+ const contributions = [...topics, ...posts];
46
43
 
47
44
  debug('Finished gathering contributions');
48
45
  return contributions;
@@ -57,7 +54,9 @@ async function processTopics({ baseUrl, username, topicType }) {
57
54
  for await (const topicsResponse of page) {
58
55
  const { topics } = topicsResponse.topic_list;
59
56
  debug(`Got ${topics.length} topics`);
60
- allTopics = allTopics.concat(topics.map((entity) => formatTopic(topicType, baseUrl, entity)));
57
+ allTopics = allTopics.concat(
58
+ topics.map((entity) => formatTopic(topicType, baseUrl, entity))
59
+ );
61
60
 
62
61
  const hasMore = topics.length === RESULTS_PER_PAGE;
63
62
  if (!hasMore) {
@@ -78,7 +77,9 @@ async function processPosts({ baseUrl, username, postType }) {
78
77
  for await (const postsResponse of page) {
79
78
  const posts = postsResponse.user_actions;
80
79
  debug(`Got ${posts.length} posts`);
81
- allPosts = allPosts.concat(posts.map((entity) => formatPost(postType, baseUrl, entity)));
80
+ allPosts = allPosts.concat(
81
+ posts.map((entity) => formatPost(postType, baseUrl, entity))
82
+ );
82
83
 
83
84
  const hasMore = posts.length === RESULTS_PER_PAGE;
84
85
  if (!hasMore) {
@@ -17,12 +17,14 @@ const TOPICS = {
17
17
 
18
18
  const TOPICS_SMALL = {
19
19
  topic_list: {
20
- topics: [{
21
- created_at: new Date('2020-04-13'),
22
- title: 'Topic 1',
23
- slug: 'slug-1',
24
- id: 1,
25
- }],
20
+ topics: [
21
+ {
22
+ created_at: new Date('2020-04-13'),
23
+ title: 'Topic 1',
24
+ slug: 'slug-1',
25
+ id: 1,
26
+ },
27
+ ],
26
28
  },
27
29
  };
28
30
 
@@ -38,14 +40,16 @@ const POSTS = {
38
40
  };
39
41
 
40
42
  const POSTS_SMALL = {
41
- user_actions: [{
42
- created_at: new Date('2020-04-13'),
43
- title: 'Post 1',
44
- slug: 'slug-1',
45
- topic_id: 1,
46
- post_id: 1,
47
- post_number: 1,
48
- }],
43
+ user_actions: [
44
+ {
45
+ created_at: new Date('2020-04-13'),
46
+ title: 'Post 1',
47
+ slug: 'slug-1',
48
+ topic_id: 1,
49
+ post_id: 1,
50
+ post_number: 1,
51
+ },
52
+ ],
49
53
  };
50
54
 
51
55
  const config = {
@@ -53,21 +57,17 @@ const config = {
53
57
  enabled: true,
54
58
  baseUrl: 'https://discourse.mozilla.org',
55
59
  username: 'user',
56
- }
60
+ },
57
61
  };
58
62
 
59
63
  test.beforeEach((t) => {
60
64
  // eslint-disable-next-line no-param-reassign
61
65
  t.context.sandbox = sinon.createSandbox();
62
66
 
63
- t.context.sandbox.stub(axios, 'get').onCall(0)
64
- .resolves({ data: TOPICS });
65
- axios.get.onCall(1)
66
- .resolves({ data: TOPICS_SMALL });
67
- axios.get.onCall(2)
68
- .resolves({ data: POSTS });
69
- axios.get.onCall(3)
70
- .resolves({ data: POSTS_SMALL });
67
+ t.context.sandbox.stub(axios, 'get').onCall(0).resolves({ data: TOPICS });
68
+ axios.get.onCall(1).resolves({ data: TOPICS_SMALL });
69
+ axios.get.onCall(2).resolves({ data: POSTS });
70
+ axios.get.onCall(3).resolves({ data: POSTS_SMALL });
71
71
  });
72
72
 
73
73
  test.afterEach.always((t) => {
@@ -115,11 +115,14 @@ test.serial('should not fetch if disabled - by enable property', async (t) => {
115
115
  t.is(contributions.length, 0);
116
116
  });
117
117
 
118
- test.serial('should not fetch if disabled - by leaving off config value', async (t) => {
119
- const contributions = await discourse.gather({});
118
+ test.serial(
119
+ 'should not fetch if disabled - by leaving off config value',
120
+ async (t) => {
121
+ const contributions = await discourse.gather({});
120
122
 
121
- t.is(contributions.length, 0);
122
- });
123
+ t.is(contributions.length, 0);
124
+ }
125
+ );
123
126
 
124
127
  test.serial('should format', async (t) => {
125
128
  const contributions = await discourse.gather(config);
@@ -148,7 +151,7 @@ test.serial('should format with custom types', async (t) => {
148
151
  ...config.discourse,
149
152
  topicType: 'Topic created!',
150
153
  postType: 'Posted!',
151
- }
154
+ },
152
155
  };
153
156
 
154
157
  const contributions = await discourse.gather(specificTypeConfig);
package/lib/fetch.js CHANGED
@@ -12,7 +12,9 @@ async function fetchAll(config) {
12
12
  validateConfig(config);
13
13
 
14
14
  debug('fetching...');
15
- const existingContributions = JSON.parse(await fs.readFile(config.outputFile));
15
+ const existingContributions = JSON.parse(
16
+ await fs.readFile(config.outputFile)
17
+ );
16
18
 
17
19
  const bugzillaResult = await bugzilla.gather(config, existingContributions);
18
20
  const githubResult = await github.gather(config, existingContributions);
@@ -31,9 +33,11 @@ async function fetchAll(config) {
31
33
  discourse.TOPICS_CATEGORY,
32
34
  wiki.WIKI_CATEGORY,
33
35
  ];
34
- const existingContributionsToSave = existingContributions.filter((activity) => {
35
- return !ALWAYS_FULL_FETCH_SOURCE_ENTRIES.includes(activity.source);
36
- });
36
+ const existingContributionsToSave = existingContributions.filter(
37
+ (activity) => {
38
+ return !ALWAYS_FULL_FETCH_SOURCE_ENTRIES.includes(activity.source);
39
+ }
40
+ );
37
41
  debug('ALREADY_EXISTING_CONTRIBUTIONS', existingContributionsToSave.length);
38
42
 
39
43
  debug('NEW_BUGZILLA_CONTRIBUTIONS', bugzillaResult);
@@ -42,22 +46,29 @@ async function fetchAll(config) {
42
46
  debug('DISCOURSE_CONTRIBUTIONS', discourseResult.length);
43
47
  debug('WIKI_CONTRIBUTIONS', wikiResult.length);
44
48
 
45
- const uniqueContributions = Array.from(new Set([
46
- ...existingContributionsToSave,
47
- ...discourseResult, // always a new fetch (previous entries removed above)
48
- ...wikiResult, // always a new fetch (previous entries removed above)
49
- ...communityPortalResult, // always a new fetch (previous entries removed above)
50
- ...githubResult,
51
- ...bugzillaResult,
52
- ]));
49
+ const uniqueContributions = Array.from(
50
+ new Set([
51
+ ...existingContributionsToSave,
52
+ ...discourseResult, // always a new fetch (previous entries removed above)
53
+ ...wikiResult, // always a new fetch (previous entries removed above)
54
+ ...communityPortalResult, // always a new fetch (previous entries removed above)
55
+ ...githubResult,
56
+ ...bugzillaResult,
57
+ ])
58
+ );
53
59
 
54
60
  if (uniqueContributions.length === existingContributions.length) {
55
61
  debug('NO_UPDATE_ABORTING');
56
62
  return;
57
63
  }
58
64
 
59
- uniqueContributions.sort((a, b) => new Date(b.createdAt) - new Date(a.createdAt));
60
- await fs.writeFile(config.outputFile, `${JSON.stringify(uniqueContributions, null, 2)}\n`);
65
+ uniqueContributions.sort(
66
+ (a, b) => new Date(b.createdAt) - new Date(a.createdAt)
67
+ );
68
+ await fs.writeFile(
69
+ config.outputFile,
70
+ `${JSON.stringify(uniqueContributions, null, 2)}\n`
71
+ );
61
72
  debug('FILE_WRITTEN');
62
73
  }
63
74
 
package/lib/fetch.test.js CHANGED
@@ -40,25 +40,39 @@ test.serial('should not write file if there was nothing to do', async (t) => {
40
40
  t.is(fs.writeFile.callCount, 0);
41
41
  });
42
42
 
43
- test.serial('should consider saved contributions if not full-fetch source', async (t) => {
44
- const existingContributions = [{ source: 'keep_me' }];
45
- JSON.parse.returns(existingContributions);
46
- github.gather.returns([{ source: 'github' }]);
43
+ test.serial(
44
+ 'should consider saved contributions if not full-fetch source',
45
+ async (t) => {
46
+ const existingContributions = [{ source: 'keep_me' }];
47
+ JSON.parse.returns(existingContributions);
48
+ github.gather.returns([{ source: 'github' }]);
47
49
 
48
- await fetch.fetchAll(config);
49
- t.is(fs.writeFile.callCount, 1);
50
- t.is(t.context.sandbox.originalJSONParse(fs.writeFile.getCall(0).args[1]).length, 2);
51
- });
50
+ await fetch.fetchAll(config);
51
+ t.is(fs.writeFile.callCount, 1);
52
+ t.is(
53
+ t.context.sandbox.originalJSONParse(fs.writeFile.getCall(0).args[1])
54
+ .length,
55
+ 2
56
+ );
57
+ }
58
+ );
52
59
 
53
- test.serial('should ignore saved contributions if full-fetch source', async (t) => {
54
- const existingContributions = [{ source: 'wiki' }, { source: 'wiki' }];
55
- JSON.parse.returns(existingContributions);
56
- github.gather.returns([{ source: 'github' }]);
60
+ test.serial(
61
+ 'should ignore saved contributions if full-fetch source',
62
+ async (t) => {
63
+ const existingContributions = [{ source: 'wiki' }, { source: 'wiki' }];
64
+ JSON.parse.returns(existingContributions);
65
+ github.gather.returns([{ source: 'github' }]);
57
66
 
58
- await fetch.fetchAll(config);
59
- t.is(fs.writeFile.callCount, 1);
60
- t.is(t.context.sandbox.originalJSONParse(fs.writeFile.getCall(0).args[1]).length, 1);
61
- });
67
+ await fetch.fetchAll(config);
68
+ t.is(fs.writeFile.callCount, 1);
69
+ t.is(
70
+ t.context.sandbox.originalJSONParse(fs.writeFile.getCall(0).args[1])
71
+ .length,
72
+ 1
73
+ );
74
+ }
75
+ );
62
76
 
63
77
  test.serial('should take all return values', async (t) => {
64
78
  communityPortal.gather.returns([{ source: 'community-portal' }]);
@@ -68,5 +82,8 @@ test.serial('should take all return values', async (t) => {
68
82
 
69
83
  await fetch.fetchAll(config);
70
84
  t.is(fs.writeFile.callCount, 1);
71
- t.is(t.context.sandbox.originalJSONParse(fs.writeFile.getCall(0).args[1]).length, 4);
85
+ t.is(
86
+ t.context.sandbox.originalJSONParse(fs.writeFile.getCall(0).args[1]).length,
87
+ 4
88
+ );
72
89
  });
package/lib/github.js CHANGED
@@ -55,8 +55,10 @@ async function gather({ github }, existingContributions = []) {
55
55
  return contribution.source === GITHUB_COMMIT_CATEGORY;
56
56
  }) || { createdAt: github.stopDate };
57
57
  const latestIssue = existingContributions.find((contribution) => {
58
- return contribution.source === GITHUB_ISSUES_CREATED_CATEGORY
59
- || contribution.source === GITHUB_PR_CREATED_CATEGORY;
58
+ return (
59
+ contribution.source === GITHUB_ISSUES_CREATED_CATEGORY ||
60
+ contribution.source === GITHUB_PR_CREATED_CATEGORY
61
+ );
60
62
  }) || { createdAt: github.stopDate };
61
63
  const latestReview = existingContributions.find((contribution) => {
62
64
  return contribution.source === GITHUB_REVIEW_CATEGORY;
@@ -70,7 +72,9 @@ async function gather({ github }, existingContributions = []) {
70
72
  } catch (error) {
71
73
  if (error.message === 'PRIVATE_SCOPE') {
72
74
  if (!github.allowPrivate) {
73
- throw new Error('GITHUB_TOKEN has private repo scope, but the config does not specify allowPrivate to fetch private repos. Are you sure you want to fetch private information?');
75
+ throw new Error(
76
+ 'GITHUB_TOKEN has private repo scope, but the config does not specify allowPrivate to fetch private repos. Are you sure you want to fetch private information?'
77
+ );
74
78
  }
75
79
  } else {
76
80
  throw error;
@@ -81,19 +85,17 @@ async function gather({ github }, existingContributions = []) {
81
85
  const issues = await processIssues(github, latestIssue.createdAt);
82
86
  const reviews = await processReviews(github, latestReview.createdAt);
83
87
  const comments = await processComments(github, latestComment.createdAt);
84
- const contributions = [
85
- ...commits,
86
- ...issues,
87
- ...reviews,
88
- ...comments,
89
- ];
88
+ const contributions = [...commits, ...issues, ...reviews, ...comments];
90
89
 
91
90
  debug('Finished gathering contributions');
92
91
  return contributions;
93
92
  }
94
93
 
95
94
  async function processIssues(github, latestCreationDate) {
96
- if (typeof github.issuesEnabled !== 'undefined' && github.issuesEnabled === false) {
95
+ if (
96
+ typeof github.issuesEnabled !== 'undefined' &&
97
+ github.issuesEnabled === false
98
+ ) {
97
99
  debug('Fetching issues is disabled, skipping!');
98
100
  return [];
99
101
  }
@@ -104,10 +106,8 @@ async function processIssues(github, latestCreationDate) {
104
106
  const lowerBoundDate = new Date(latestCreationDate);
105
107
  const generatedPeriod = periodGenerator(github.stopDate, lowerBoundDate);
106
108
  for await (const periodChunk of generatedPeriod) {
107
- const currentPage = pageGenerator(
108
- github,
109
- periodChunk,
110
- (period, page) => getIssuePage(github, 'author', period, page)
109
+ const currentPage = pageGenerator(github, periodChunk, (period, page) =>
110
+ getIssuePage(github, 'author', period, page)
111
111
  );
112
112
  for await (const issues of currentPage) {
113
113
  debug(`Got ${issues.length} issues`);
@@ -121,7 +121,10 @@ async function processIssues(github, latestCreationDate) {
121
121
  }
122
122
 
123
123
  async function processCommits(github, latestCreationDate) {
124
- if (typeof github.commitsEnabled !== 'undefined' && github.commitsEnabled === false) {
124
+ if (
125
+ typeof github.commitsEnabled !== 'undefined' &&
126
+ github.commitsEnabled === false
127
+ ) {
125
128
  debug('Fetching commits is disabled, skipping!');
126
129
  return [];
127
130
  }
@@ -132,10 +135,8 @@ async function processCommits(github, latestCreationDate) {
132
135
  const lowerBoundDate = new Date(latestCreationDate);
133
136
  const generatedPeriod = periodGenerator(github.stopDate, lowerBoundDate);
134
137
  for await (const periodChunk of generatedPeriod) {
135
- const currentPage = pageGenerator(
136
- github,
137
- periodChunk,
138
- (period, page) => getCommitPage(github, period, page)
138
+ const currentPage = pageGenerator(github, periodChunk, (period, page) =>
139
+ getCommitPage(github, period, page)
139
140
  );
140
141
  for await (const commits of currentPage) {
141
142
  debug(`Got ${commits.length} commits`);
@@ -149,7 +150,10 @@ async function processCommits(github, latestCreationDate) {
149
150
  }
150
151
 
151
152
  async function processReviews(github, latestCreationDate) {
152
- if (typeof github.reviewsEnabled !== 'undefined' && github.reviewsEnabled === false) {
153
+ if (
154
+ typeof github.reviewsEnabled !== 'undefined' &&
155
+ github.reviewsEnabled === false
156
+ ) {
153
157
  debug('Fetching reviews is disabled, skipping!');
154
158
  return [];
155
159
  }
@@ -184,19 +188,30 @@ async function processReviews(github, latestCreationDate) {
184
188
  // Now that we have all the PRs, we need to fetch the reviews
185
189
  const allReviews = [];
186
190
 
187
- const prReviewsList = getPRReviews(allPRs.flat(), github.username, github.delayMsPerRequest);
191
+ const prReviewsList = getPRReviews(
192
+ allPRs.flat(),
193
+ github.username,
194
+ github.delayMsPerRequest
195
+ );
188
196
  for await (const prReviews of prReviewsList) {
189
197
  allReviews.push(prReviews);
190
198
  }
191
199
 
192
- const processedReviews = processEntities(github, allReviews.flat(), prTitleMap);
200
+ const processedReviews = processEntities(
201
+ github,
202
+ allReviews.flat(),
203
+ prTitleMap
204
+ );
193
205
  return processedReviews.filter((review) => {
194
206
  return new Date(review.createdAt) > new Date(latestCreationDate);
195
207
  });
196
208
  }
197
209
 
198
210
  async function processComments(github, latestCreationDate) {
199
- if (typeof github.commentsEnabled !== 'undefined' && github.commentsEnabled === false) {
211
+ if (
212
+ typeof github.commentsEnabled !== 'undefined' &&
213
+ github.commentsEnabled === false
214
+ ) {
200
215
  debug('Fetching comments is disabled, skipping!');
201
216
  return [];
202
217
  }
@@ -225,8 +240,11 @@ async function processComments(github, latestCreationDate) {
225
240
  }
226
241
 
227
242
  const commentTitleMap = new Map();
228
- allCommentedIssues.flat()
229
- .forEach((commentIssue) => commentTitleMap.set(commentIssue.url, commentIssue.title));
243
+ allCommentedIssues
244
+ .flat()
245
+ .forEach((commentIssue) =>
246
+ commentTitleMap.set(commentIssue.url, commentIssue.title)
247
+ );
230
248
 
231
249
  // Now that we have all the commented issues, we need to fetch the actual comments
232
250
  const allComments = [];
@@ -240,7 +258,11 @@ async function processComments(github, latestCreationDate) {
240
258
  allComments.push(comments);
241
259
  }
242
260
 
243
- const processedComments = processEntities(github, allComments.flat(), commentTitleMap);
261
+ const processedComments = processEntities(
262
+ github,
263
+ allComments.flat(),
264
+ commentTitleMap
265
+ );
244
266
  return processedComments.filter((comment) => {
245
267
  return new Date(comment.createdAt) > new Date(latestCreationDate);
246
268
  });
@@ -274,10 +296,14 @@ function getNextPeriod(stopDate, period, lowerBoundDate) {
274
296
 
275
297
  async function* periodGenerator(stopDate, lowerBoundDate) {
276
298
  const date = new Date();
277
- const firstOfThisMonth = `${date.getFullYear()}-${getPadded(date.getMonth() + 1)}-01`;
299
+ const firstOfThisMonth = `${date.getFullYear()}-${getPadded(
300
+ date.getMonth() + 1
301
+ )}-01`;
278
302
  date.setMonth(date.getMonth() + 1);
279
303
  date.setDate(0);
280
- const lastOfThisMonth = `${date.getFullYear()}-${getPadded(date.getMonth() + 1)}-${date.getDate()}`;
304
+ const lastOfThisMonth = `${date.getFullYear()}-${getPadded(
305
+ date.getMonth() + 1
306
+ )}-${date.getDate()}`;
281
307
  let currentPeriod = [lastOfThisMonth, firstOfThisMonth];
282
308
  while (true) {
283
309
  yield currentPeriod;
@@ -310,7 +336,11 @@ async function* pageGenerator(github, period, cb, { skipProcessing } = {}) {
310
336
  }
311
337
  }
312
338
 
313
- async function getCommitPage({ username, delayMsPerRequest }, commitsPeriod, page) {
339
+ async function getCommitPage(
340
+ { username, delayMsPerRequest },
341
+ commitsPeriod,
342
+ page
343
+ ) {
314
344
  const [before, after] = commitsPeriod;
315
345
 
316
346
  debug(`Getting commits page ${page} between ${after} and ${before}`);
@@ -383,7 +413,9 @@ async function* getPRReviews(prList, reviewerUsername, delay) {
383
413
  debug('Getting PR reviews');
384
414
  for await (const pr of prList) {
385
415
  try {
386
- const [, owner, repo] = /github\.com\/repos\/(.+)\/(.*)/.exec(pr.repository_url);
416
+ const [, owner, repo] = /github\.com\/repos\/(.+)\/(.*)/.exec(
417
+ pr.repository_url
418
+ );
387
419
  // We're waiting for a bit here, as we've previously hit a secondary GitHub rate limit...
388
420
  await waitFor(delay ?? DELAY_FETCHING_MS);
389
421
  debug(`Fetching reviews for ${owner}/${repo} PR ${pr.number}`);
@@ -393,7 +425,9 @@ async function* getPRReviews(prList, reviewerUsername, delay) {
393
425
  pull_number: pr.number,
394
426
  });
395
427
 
396
- const onlyMyReviews = items.filter((review) => review.user.login === reviewerUsername);
428
+ const onlyMyReviews = items.filter(
429
+ (review) => review.user.login === reviewerUsername
430
+ );
397
431
 
398
432
  yield onlyMyReviews;
399
433
  } catch (error) {
@@ -409,7 +443,9 @@ async function* getComments(issueList, commenterUsername, delay) {
409
443
  debug('Getting comments');
410
444
  for await (const issue of issueList) {
411
445
  try {
412
- const [, owner, repo] = /github\.com\/repos\/(.+)\/(.*)/.exec(issue.repository_url);
446
+ const [, owner, repo] = /github\.com\/repos\/(.+)\/(.*)/.exec(
447
+ issue.repository_url
448
+ );
413
449
  // We're waiting for a bit here, as we've previously hit a secondary GitHub rate limit...
414
450
  await waitFor(delay ?? DELAY_FETCHING_MS);
415
451
  debug(`Fetching comments for ${owner}/${repo} issue ${issue.number}`);
@@ -419,7 +455,9 @@ async function* getComments(issueList, commenterUsername, delay) {
419
455
  issue_number: issue.number,
420
456
  });
421
457
 
422
- const onlyMyComments = items.filter((comment) => comment.user.login === commenterUsername);
458
+ const onlyMyComments = items.filter(
459
+ (comment) => comment.user.login === commenterUsername
460
+ );
423
461
 
424
462
  yield onlyMyComments;
425
463
  } catch (error) {
@@ -495,7 +533,9 @@ function formatIssue(types, entity) {
495
533
  type: entity.pull_request
496
534
  ? types?.createdPR || TYPE_CREATED_PR
497
535
  : types?.createdIssue || TYPE_CREATED_ISSUE,
498
- source: entity.pull_request ? GITHUB_PR_CREATED_CATEGORY : GITHUB_ISSUES_CREATED_CATEGORY,
536
+ source: entity.pull_request
537
+ ? GITHUB_PR_CREATED_CATEGORY
538
+ : GITHUB_ISSUES_CREATED_CATEGORY,
499
539
  };
500
540
  }
501
541