Skip to content

Commit 5d06691

Browse files
committed
Feature: Web version announcement
1 parent 1d60392 commit 5d06691

15 files changed

Lines changed: 188 additions & 45 deletions

File tree

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
# Changelog
22
All notable changes to this project will be documented in this file.
33

4+
## [2.14.0] - 2024-03-03
5+
### Added
6+
- Announcing the web version development.
7+
- Improved telemetry, by adding a reviewers summary.
8+
- "Build with" link in the footer.
9+
410
## [2.13.0] - 2024-02-10
511
### Added
612
- `exclude` option to exclude specific users from the stats.

README.md

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -249,21 +249,33 @@ Used by hundreds of successful teams:
249249
| :--: | :--: | :--: | :--: | :--: | :--: | :--: | :--: |
250250
| <a href="https://www.intel.com"><img src="https://avatars.githubusercontent.com/u/17888862?s=200&v=4" width="64"></a><br/>**Intel** | <a href="https://auth0.com/"><img src="https://avatars.githubusercontent.com/u/2824157?s=200&v=4" width="64"></a><br/>**Auth0** | <a href="https://www.additionwealth.com/"><img src="https://avatars.githubusercontent.com/u/86253902?s=200&v=4" width="64"></a><br/>**Addition** | <a href="https://fauna.com/"><img src="https://avatars.githubusercontent.com/u/1477000?s=200&v=4" width="64"></a><br/>**Fauna** | <a href="http://open.cdc.gov/"><img src="https://avatars.githubusercontent.com/u/12104975?s=200&v=4" width="64"></a><br/>**CDC** | <a href="https://www.wecasa.fr/"><img src="https://avatars.githubusercontent.com/u/56955553?s=200&v=4" width="64"></a><br/>**Wecasa** | <a href="https://bolt.eu/"><img src="https://avatars.githubusercontent.com/u/37693190?s=200&v=4" width="64"></a><br/>**Bolt** | <a href="https://republic.com/"><img src="https://avatars.githubusercontent.com/u/18252987?s=200&v=4" width="64"></a><br/>**Republic** |
251251

252-
## Author
252+
## Authors
253253

254254
|<a href="https://github.com/manuelmhtr"><img src="https://avatars.githubusercontent.com/u/1031639?v=4" width="32"></a>|[@manuelmhtr](https://github.com/manuelmhtr)<br/>🇲🇽 Guadalajara, MX|
255255
| -- | :-- |
256+
|<a href="https://github.com/CarlosCRG19"><img src="https://avatars.githubusercontent.com/u/61464973?v=4" width="32"></a>|[@CarlosCRG19](https://github.com/CarlosCRG19)<br/>🇲🇽 Colima, MX|
256257

257258

258259
## Help
259260

260-
This project is maintained by a single person, considering supporting the project by:
261+
This project is maintained by a small team, considering supporting the project by:
261262

262263
* ⭐ Star this repo.
263-
* Sharing your [feedback](https://github.com/flowwer-dev/pull-request-stats/discussions/new).
264-
* Joining the [community](https://discord.gg/SGYbZkac).
264+
* Sharing your [feedback](https://forms.gle/xNakBCbfjEnVvmcZ7).
265+
* Joining the [community](https://discord.gg/wk5zy5aAZQ).
265266
* Becoming a [sponsor](https://github.com/sponsors/manuelmhtr).
266267

267-
### License
268+
## NEW: We are building the web version! ⚡
269+
270+
![](/assets/web-banner.png)
271+
272+
Exciting News! After receiving numerous requests from developers, we're actively developing a stand-alone version of this action!
273+
274+
**Get early access** by filling out [this form](https://c4tj3h4y5wh.typeform.com/to/Ejo56p27).
275+
276+
Psst! Current sponsors will receive early access and free premium feature for a limited time 🤫
277+
278+
279+
## License
268280

269281
MIT

assets/web-banner.png

342 KB
Loading

dist/index.js

Lines changed: 41 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -41280,7 +41280,7 @@ const run = async (params) => {
4128041280

4128141281
if (alreadyPublished(pullRequest)) {
4128241282
core.info('Skipping execution because stats are published already');
41283-
return;
41283+
return null;
4128441284
}
4128541285

4128641286
const pulls = await getPulls({
@@ -41306,7 +41306,7 @@ const run = async (params) => {
4130641306
core.debug('Stats table built successfully');
4130741307

4130841308
const content = buildComment({
41309-
table, periodLength, org, repos,
41309+
table, periodLength, org, repos, isSponsor: params.isSponsor,
4131041310
});
4131141311
core.debug(`Commit content built successfully: ${content}`);
4131241312

@@ -41318,15 +41318,21 @@ const run = async (params) => {
4131841318
await core.setOutput('resultsMd', content);
4131941319
await core.setOutput('resultsJson', whParams);
4132041320

41321-
if (!pullRequestId) return;
41322-
await postComment({
41323-
octokit,
41324-
content,
41325-
publishAs,
41326-
pullRequestId,
41327-
currentBody: pullRequest.body,
41328-
});
41329-
core.debug('Posted comment successfully');
41321+
if (pullRequestId) {
41322+
await postComment({
41323+
octokit,
41324+
content,
41325+
publishAs,
41326+
pullRequestId,
41327+
currentBody: pullRequest.body,
41328+
});
41329+
core.debug('Posted comment successfully');
41330+
}
41331+
41332+
return {
41333+
reviewers,
41334+
pullRequest,
41335+
};
4133041336
};
4133141337

4133241338
module.exports = async (params) => {
@@ -41340,8 +41346,8 @@ module.exports = async (params) => {
4134041346

4134141347
try {
4134241348
telemetry.start(params);
41343-
await run({ ...params, isSponsor, octokit });
41344-
telemetry.success();
41349+
const results = await run({ ...params, isSponsor, octokit });
41350+
telemetry.success(results);
4134541351
} catch (error) {
4134641352
telemetry.error(error);
4134741353
throw error;
@@ -41392,6 +41398,9 @@ const PR_BY_ID_QUERY = `
4139241398
url
4139341399
body
4139441400
number
41401+
author {
41402+
login
41403+
}
4139541404
comments(last: 100) {
4139641405
nodes {
4139741406
author {
@@ -41703,11 +41712,13 @@ module.exports = ({
4170341712
table,
4170441713
org,
4170541714
repos,
41715+
isSponsor,
4170641716
periodLength,
4170741717
}) => {
4170841718
const sources = buildSources({ buildGithubLink, org, repos });
4170941719
const message = t('table.subtitle', { sources, count: periodLength });
41710-
return `## ${t('table.title')}\n${message}:\n${table}`;
41720+
const footer = isSponsor ? '' : `\n${t('table.footer')}`;
41721+
return `## ${t('table.title')}\n${message}:\n${table}${footer}`;
4171141722
};
4171241723

4171341724

@@ -43360,11 +43371,12 @@ class Telemetry {
4336043371
});
4336143372
}
4336243373

43363-
success() {
43374+
success(results) {
4336443375
if (!this.useTelemetry) return;
4336543376
sendSuccess({
4336643377
timeMs: new Date() - this.startDate,
4336743378
tracker: this.tracker,
43379+
...(results || {}),
4336843380
});
4336943381
}
4337043382
}
@@ -43437,14 +43449,25 @@ module.exports = ({
4343743449
/***/ 7513:
4343843450
/***/ ((module) => {
4343943451

43440-
module.exports = ({ tracker, timeMs }) => {
43452+
module.exports = ({
43453+
timeMs,
43454+
tracker,
43455+
pullRequest,
43456+
reviewers: reviewersInput,
43457+
}) => {
4344143458
const timeSec = Math.floor(timeMs / 1000);
4344243459
const timeMin = Math.floor(timeMs / 60000);
43460+
const prAuthor = pullRequest?.author?.login;
43461+
const reviewers = (reviewersInput || []).map((r) => r?.author?.login);
43462+
const reviewersCount = reviewers.length;
4344343463

4344443464
tracker.track('success', {
4344543465
timeMs,
4344643466
timeSec,
4344743467
timeMin,
43468+
prAuthor,
43469+
reviewers,
43470+
reviewersCount,
4344843471
});
4344943472
};
4345043473

@@ -48032,7 +48055,7 @@ module.exports = JSON.parse('{"name":"mixpanel","description":"A simple server-s
4803248055
/***/ ((module) => {
4803348056

4803448057
"use strict";
48035-
module.exports = JSON.parse('{"name":"pull-request-stats","version":"2.13.0","description":"Github action to print relevant stats about Pull Request reviewers","main":"dist/index.js","type":"commonjs","scripts":{"build":"eslint src && ncc build src/index.js -o dist -a","test":"jest","lint":"eslint ./"},"keywords":[],"author":"Manuel de la Torre","license":"MIT","jest":{"testEnvironment":"node","testMatch":["**/?(*.)+(spec|test).[jt]s?(x)"]},"dependencies":{"@actions/core":"^1.10.1","@actions/github":"^6.0.0","axios":"^1.6.7","humanize-duration":"^3.31.0","i18n-js":"^3.9.2","jsurl":"^0.1.5","lodash.get":"^4.4.2","markdown-table":"^2.0.0","mixpanel":"^0.18.0"},"devDependencies":{"@vercel/ncc":"^0.38.1","eslint":"^8.56.0","eslint-config-airbnb-base":"^15.0.0","eslint-plugin-import":"^2.29.1","eslint-plugin-jest":"^27.6.3","jest":"^29.7.0"},"funding":"https://github.com/sponsors/manuelmhtr","packageManager":"yarn@4.1.0"}');
48058+
module.exports = JSON.parse('{"name":"pull-request-stats","version":"2.14.0","description":"Github action to print relevant stats about Pull Request reviewers","main":"dist/index.js","type":"commonjs","scripts":{"build":"eslint src && ncc build src/index.js -o dist -a","test":"jest","lint":"eslint ./"},"keywords":[],"author":"Manuel de la Torre","license":"MIT","jest":{"testEnvironment":"node","testMatch":["**/?(*.)+(spec|test).[jt]s?(x)"]},"dependencies":{"@actions/core":"^1.10.1","@actions/github":"^6.0.0","axios":"^1.6.7","humanize-duration":"^3.31.0","i18n-js":"^3.9.2","jsurl":"^0.1.5","lodash.get":"^4.4.2","markdown-table":"^2.0.0","mixpanel":"^0.18.0"},"devDependencies":{"@vercel/ncc":"^0.38.1","eslint":"^8.56.0","eslint-config-airbnb-base":"^15.0.0","eslint-plugin-import":"^2.29.1","eslint-plugin-jest":"^27.6.3","jest":"^29.7.0"},"funding":"https://github.com/sponsors/manuelmhtr","packageManager":"yarn@4.1.0"}');
4803648059

4803748060
/***/ }),
4803848061

@@ -48056,7 +48079,7 @@ module.exports = JSON.parse('{"slack":{"logs":{"notConfigured":"Slack integratio
4805648079
/***/ ((module) => {
4805748080

4805848081
"use strict";
48059-
module.exports = JSON.parse('{"title":"Pull reviewers stats","icon":"https://s3.amazonaws.com/manuelmhtr.assets/flowwer/logo/logo-1024px.png","subtitle":{"one":"Stats of the last day for {{sources}}","other":"Stats of the last {{count}} days for {{sources}}"},"sources":{"separator":", ","fullList":"{{firsts}} and {{last}}","andOthers":"{{firsts}} and {{count}} others"},"columns":{"avatar":"","username":"User","timeToReview":"Time to review","totalReviews":"Total reviews","totalComments":"Total comments"}}');
48082+
module.exports = JSON.parse('{"title":"Pull reviewers stats","icon":"https://s3.amazonaws.com/manuelmhtr.assets/flowwer/logo/logo-1024px.png","subtitle":{"one":"Stats of the last day for {{sources}}","other":"Stats of the last {{count}} days for {{sources}}"},"sources":{"separator":", ","fullList":"{{firsts}} and {{last}}","andOthers":"{{firsts}} and {{count}} others"},"columns":{"avatar":"","username":"User","timeToReview":"Time to review","totalReviews":"Total reviews","totalComments":"Total comments"},"footer":"<sup>⚡️ [Pull request stats](https://bit.ly/pull-request-stats)</sup>"}');
4806048083

4806148084
/***/ })
4806248085

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "pull-request-stats",
3-
"version": "2.13.0",
3+
"version": "2.14.0",
44
"description": "Github action to print relevant stats about Pull Request reviewers",
55
"main": "dist/index.js",
66
"type": "commonjs",

src/execute.js

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ const run = async (params) => {
3939

4040
if (alreadyPublished(pullRequest)) {
4141
core.info('Skipping execution because stats are published already');
42-
return;
42+
return null;
4343
}
4444

4545
const pulls = await getPulls({
@@ -65,7 +65,7 @@ const run = async (params) => {
6565
core.debug('Stats table built successfully');
6666

6767
const content = buildComment({
68-
table, periodLength, org, repos,
68+
table, periodLength, org, repos, isSponsor: params.isSponsor,
6969
});
7070
core.debug(`Commit content built successfully: ${content}`);
7171

@@ -77,15 +77,21 @@ const run = async (params) => {
7777
await core.setOutput('resultsMd', content);
7878
await core.setOutput('resultsJson', whParams);
7979

80-
if (!pullRequestId) return;
81-
await postComment({
82-
octokit,
83-
content,
84-
publishAs,
85-
pullRequestId,
86-
currentBody: pullRequest.body,
87-
});
88-
core.debug('Posted comment successfully');
80+
if (pullRequestId) {
81+
await postComment({
82+
octokit,
83+
content,
84+
publishAs,
85+
pullRequestId,
86+
currentBody: pullRequest.body,
87+
});
88+
core.debug('Posted comment successfully');
89+
}
90+
91+
return {
92+
reviewers,
93+
pullRequest,
94+
};
8995
};
9096

9197
module.exports = async (params) => {
@@ -99,8 +105,8 @@ module.exports = async (params) => {
99105

100106
try {
101107
telemetry.start(params);
102-
await run({ ...params, isSponsor, octokit });
103-
telemetry.success();
108+
const results = await run({ ...params, isSponsor, octokit });
109+
telemetry.success(results);
104110
} catch (error) {
105111
telemetry.error(error);
106112
throw error;

src/fetchers/fetchPullRequestById/__tests__/parser.test.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ const input = {
55
id: 'PR_kwDODiVEWs455SUz',
66
url: 'https://github.com/zenfi/api/pull/493',
77
number: 493,
8+
author: {
9+
login: 'author1',
10+
},
811
comments: {
912
nodes: [
1013
{
@@ -28,6 +31,9 @@ const expectedOutput = {
2831
id: 'PR_kwDODiVEWs455SUz',
2932
url: 'https://github.com/zenfi/api/pull/493',
3033
number: 493,
34+
author: {
35+
login: 'author1',
36+
},
3137
comments: [
3238
{
3339
author: {

src/fetchers/fetchPullRequestById/index.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ const PR_BY_ID_QUERY = `
88
url
99
body
1010
number
11+
author {
12+
login
13+
}
1114
comments(last: 100) {
1215
nodes {
1316
author {

src/i18n/locales/en-US/table.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,6 @@
1616
"timeToReview": "Time to review",
1717
"totalReviews": "Total reviews",
1818
"totalComments": "Total comments"
19-
}
19+
},
20+
"footer": "<sup>⚡️ [Pull request stats](https://bit.ly/pull-request-stats)</sup>"
2021
}

src/interactors/__tests__/buildComment.test.js

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1+
const { t } = require('../../i18n');
12
const buildComment = require('../buildComment');
23
const { getRepoName } = require('../../utils');
34

45
const TABLE_MOCK = 'TABLE';
56
const ORG = 'org';
67
const REPO1 = 'org/repo1';
78
const REPO2 = 'org/repo2';
9+
const FOOTER = t('table.footer');
810

911
const linkOrg = (org) => `[${org}](https://github.com/${org})`;
1012

@@ -18,7 +20,7 @@ describe('Interactors | .buildComment', () => {
1820
const message = `Stats of the last day for ${linkOrg(ORG)}:`;
1921

2022
it('builds the message in singular', () => {
21-
const expected = `${title}\n${message}\n${TABLE_MOCK}`;
23+
const expected = `${title}\n${message}\n${TABLE_MOCK}\n${FOOTER}`;
2224
const response = buildComment({ periodLength, table: TABLE_MOCK, org: ORG });
2325
expect(response).toEqual(expected);
2426
});
@@ -29,7 +31,7 @@ describe('Interactors | .buildComment', () => {
2931
const message = `Stats of the last 365 days for ${linkOrg(ORG)}:`;
3032

3133
it('builds the message in singular', () => {
32-
const expected = `${title}\n${message}\n${TABLE_MOCK}`;
34+
const expected = `${title}\n${message}\n${TABLE_MOCK}\n${FOOTER}`;
3335
const response = buildComment({ periodLength, table: TABLE_MOCK, org: ORG });
3436
expect(response).toEqual(expected);
3537
});
@@ -41,9 +43,26 @@ describe('Interactors | .buildComment', () => {
4143
const message = `Stats of the last day for ${linkRepo(REPO1)} and ${linkRepo(REPO2)}:`;
4244

4345
it('builds the message in singular', () => {
44-
const expected = `${title}\n${message}\n${TABLE_MOCK}`;
46+
const expected = `${title}\n${message}\n${TABLE_MOCK}\n${FOOTER}`;
4547
const response = buildComment({ periodLength, table: TABLE_MOCK, repos });
4648
expect(response).toEqual(expected);
4749
});
4850
});
51+
52+
describe('when is a sponsor', () => {
53+
const isSponsor = true;
54+
const periodLength = 1;
55+
const message = `Stats of the last day for ${linkOrg(ORG)}:`;
56+
57+
it('removes the footer', () => {
58+
const expected = `${title}\n${message}\n${TABLE_MOCK}`;
59+
const response = buildComment({
60+
isSponsor,
61+
periodLength,
62+
org: ORG,
63+
table: TABLE_MOCK,
64+
});
65+
expect(response).toEqual(expected);
66+
});
67+
});
4968
});

0 commit comments

Comments
 (0)