Skip to content
This repository was archived by the owner on Nov 8, 2020. It is now read-only.

Commit 156ae6c

Browse files
committed
Fix after GitHub's interface has changed // ghuser-io/ghuser.io#172
1 parent 0b3172e commit 156ae6c

File tree

4 files changed

+26
-102
lines changed

4 files changed

+26
-102
lines changed

README.md

Lines changed: 9 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -67,47 +67,11 @@ Normally in order to retrieve all repositories a user has interacted with, one s
6767
[GitHub Events API](https://stackoverflow.com/a/37554614/1855917). Unfortunately it returns
6868
[only the last 90 days](https://stackoverflow.com/a/38274468/1855917), so we don't use it.
6969

70-
Instead we noticed that the "Contribution Activity" on the
71-
[profile pages](https://github.com/AurelienLourot) queries such URLs in the background:
72-
73-
* https://github.com/users/AurelienLourot/created_repositories?from=2018-05-17&to=2018-05-17
74-
* https://github.com/users/AurelienLourot/created_pull_request_reviews?from=2018-05-17&to=2018-05-17
75-
* https://github.com/users/AurelienLourot/created_issues?from=2018-07-10&to=2018-07-10
76-
77-
So we're doing the same :)
78-
79-
> **NOTES**:
80-
>
81-
> * It seems like `created_issues` URLs don't deliver "hot issues" (issues which received
82-
> more comments than others):
83-
>
84-
> ```bash
85-
> $ curl -s "https://github.com/users/AurelienLourot/created_issues?from=2015-09-23&to=2015-09-23"
86-
> <div class="profile-rollup-content">
87-
> </div>
88-
> ```
89-
>
90-
> To get these, we also query the profile itself:
91-
>
92-
> ```bash
93-
> $ curl -s "https://github.com/AurelienLourot?from=2015-09-23" | grep issues/
94-
> <a class="text-gray-dark" href="/jfrog/build-info/issues/60">Publish properties aren&#39;t used by build-info-extractor-gradle?</a>
95-
> ```
96-
>
97-
> * In the past we used to get the pull requests from a `created_pull_requests` URL but this got
98-
> removed. We now get the pull requests from the profile itself as well:
99-
>
100-
> ```bash
101-
> $ curl -s "https://github.com/AurelienLourot?from=2017-08-28" | grep pull/
102-
> <a href="/tt-gf/ant-ivy/pull/2" class="content-title no-underline">
103-
> ```
104-
105-
> * Same now with `created_commits`:
106-
>
107-
> ```bash
108-
> $ curl -s "https://github.com/AurelienLourot?from=2017-08-27" | grep commits?
109-
> <a href="/AurelienLourot/mybeir.ut/commits?author=AurelienLourot&amp;since=2017-08-27&amp;until=2017-08-28" class="f6 muted-link ml-1">
110-
> ```
70+
Instead we noticed that the "Contribution Activity" section's content on the
71+
[profile pages](https://github.com/AurelienLourot) comes from URLs like
72+
https://github.com/AurelienLourot?from=2018-10-09 .
73+
74+
So we're fetching these URLs too and parsing their output.
11175

11276
### Why is it so slow?
11377

@@ -135,6 +99,10 @@ doesn't discover commits in forks.
13599

136100
## Changelog
137101

102+
**2.2.4** (2018-11-11):
103+
* [ghuser-io/ghuser.io#172](https://github.com/ghuser-io/ghuser.io/issues/172) Fix after GitHub's
104+
interface has changed. The `created_issues` "endpoint" is gone.
105+
138106
**2.2.3** (2018-10-20):
139107
* [ghuser-io/ghuser.io#172](https://github.com/ghuser-io/ghuser.io/issues/172) Fix after GitHub's
140108
interface has changed. The `created_commits` "endpoint" is gone.

index.js

Lines changed: 1 addition & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -83,39 +83,6 @@
8383
};
8484

8585
const getContribs = async (user, joinDate, since, until, ora, console, alsoIssues) => {
86-
const issuesHtmlToRepos = html => {
87-
const repos = new Set();
88-
89-
const handler = new htmlparser.DefaultHandler((error, dom) => {});
90-
const parser = new htmlparser.Parser(handler);
91-
parser.parseComplete(html);
92-
for (let i = 0; i < handler.dom.length; ++i) {
93-
if (handler.dom[i].type === 'tag' && handler.dom[i].name === 'div') {
94-
const div1 = handler.dom[i].children;
95-
for (let j = 0; j < div1.length; ++j) {
96-
if (div1[j].type === 'tag' && div1[j].name === 'div') {
97-
const div2 = div1[j].children;
98-
for (let k = 0; k < div2.length; ++k) {
99-
if (div2[k].type === 'tag' && div2[k].name === 'button') {
100-
const button = div2[k].children;
101-
for (let l = 0; l < button.length; ++l) {
102-
if (button[l].type === 'tag' && button[l].name === 'span') {
103-
const span = button[l].children[0].data.trim();
104-
if (span) {
105-
repos.add(span);
106-
}
107-
}
108-
}
109-
}
110-
}
111-
}
112-
}
113-
}
114-
}
115-
116-
return repos;
117-
};
118-
11986
const bigHtmlToRepos = (html, type) => { // type: 'issues', 'pull' or 'commits'
12087
const repos = new Set();
12188

@@ -177,18 +144,7 @@
177144
)).text();
178145
const commitsRepos = bigHtmlToRepos(bigHtml, 'commits');
179146
const prsRepos = bigHtmlToRepos(bigHtml, 'pull');
180-
181-
let issuesRepos = [];
182-
let hotIssuesRepos = [];
183-
if (alsoIssues) {
184-
const userIssues = await fetchRetry(
185-
`https://github.com/users/${user}/created_issues?from=${currDateStr}&to=${currDateStr}`,
186-
);
187-
const userIssuesHtml = await userIssues.text();
188-
issuesRepos = issuesHtmlToRepos(userIssuesHtml);
189-
190-
hotIssuesRepos = bigHtmlToRepos(bigHtml, 'issues');
191-
}
147+
const issuesRepos = alsoIssues ? bigHtmlToRepos(bigHtml, 'issues') : [];
192148

193149
progressSpinner.stop(); // temporary stop for logging
194150
for (const repo of commitsRepos) {
@@ -203,10 +159,6 @@
203159
console.log(`${currDateStr}: (issues) ${repo}`);
204160
result.add(repo);
205161
}
206-
for (const repo of hotIssuesRepos) {
207-
console.log(`${currDateStr}: (hot issues) ${repo}`);
208-
result.add(repo);
209-
}
210162
progressSpinner.start(
211163
progressMsg(false, alsoIssues, ++numOfQueriedDays, numOfDaysToQuery)
212164
);

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,6 @@
7373
".js"
7474
],
7575
"check-coverage": true,
76-
"lines": 70
76+
"lines": 75
7777
}
7878
}

test.js

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@ const ora = string => {
2323
};
2424

2525
test('fetches commits and PRs', async t => {
26-
/* AurelienLourot had the following activity:
27-
* 2017-08-26: nothing
28-
* 2017-08-27: 14 commits in AurelienLourot/mybeir.ut
29-
* 2017-08-28: 1 PR in tt-gf/ant-ivy */
26+
// AurelienLourot had the following activity:
27+
// * 2017-08-26: nothing
28+
// * 2017-08-27: 14 commits in AurelienLourot/mybeir.ut
29+
// * 2017-08-28: 1 PR in tt-gf/ant-ivy
3030

3131
const result = await m.fetch('AurelienLourot', '2017-08-26', '2017-08-28', ora, console);
3232

@@ -42,19 +42,23 @@ test('fetches commits and PRs', async t => {
4242
t.true(result.has('AurelienLourot/myberl.in'));
4343
});
4444

45-
test('fetches issues', async t => {
46-
/* RichardLitt had the following activity:
47-
* 2018-08-07: 1 issue in orbitdb/welcome */
45+
test('fetches issues and reviewed pull requests', async t => {
46+
// RichardLitt had the following activity:
47+
// * 2018-08-07: 1 issue in orbitdb/welcome
48+
// 4 reviewed pull requests in rtfd/readthedocs.org
4849

4950
const result = await m.fetch('RichardLitt', '2018-08-07', '2018-08-07', ora, console, true);
50-
t.is(result.size, 1);
51+
t.is(result.size, 2);
5152
t.true(result.has('orbitdb/welcome'));
53+
t.true(result.has('rtfd/readthedocs.org'));
5254
});
5355

5456
test('fetches hot issues', async t => {
55-
/* AurelienLourot had the following activity:
56-
* 2015-09-23: 1 commit in AurelienLourot/AurelienLourot.github.io
57-
1 hot issue in jfrog/build-info */
57+
// Hot issues are issues which received more comments than others.
58+
//
59+
// AurelienLourot had the following activity:
60+
// * 2015-09-23: 1 commit in AurelienLourot/AurelienLourot.github.io
61+
// 1 hot issue in jfrog/build-info
5862

5963
const result = await m.fetch('AurelienLourot', '2015-09-23', '2015-09-23', ora, console, true);
6064
t.is(result.size, 2);

0 commit comments

Comments
 (0)