|
83 | 83 | }; |
84 | 84 |
|
85 | 85 | 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 | | - |
119 | 86 | const bigHtmlToRepos = (html, type) => { // type: 'issues', 'pull' or 'commits' |
120 | 87 | const repos = new Set(); |
121 | 88 |
|
|
177 | 144 | )).text(); |
178 | 145 | const commitsRepos = bigHtmlToRepos(bigHtml, 'commits'); |
179 | 146 | 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') : []; |
192 | 148 |
|
193 | 149 | progressSpinner.stop(); // temporary stop for logging |
194 | 150 | for (const repo of commitsRepos) { |
|
203 | 159 | console.log(`${currDateStr}: (issues) ${repo}`); |
204 | 160 | result.add(repo); |
205 | 161 | } |
206 | | - for (const repo of hotIssuesRepos) { |
207 | | - console.log(`${currDateStr}: (hot issues) ${repo}`); |
208 | | - result.add(repo); |
209 | | - } |
210 | 162 | progressSpinner.start( |
211 | 163 | progressMsg(false, alsoIssues, ++numOfQueriedDays, numOfDaysToQuery) |
212 | 164 | ); |
|
0 commit comments