Skip to content

Commit 065c3a0

Browse files
committed
Fetch issues directly from GitHub using the unauthenticated Search API
1 parent 811f4c4 commit 065c3a0

File tree

1 file changed

+18
-4
lines changed

1 file changed

+18
-4
lines changed

webpack/js/components.js

+18-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import VueSelect from 'vue-select';
2+
import {Octokit} from '@octokit/rest';
23

34
import {hydrateAppWithData} from "./hydration";
45

@@ -40,7 +41,7 @@ export const IssueCard = {
4041
</h4>
4142
<p class="is-size-6">
4243
<a
43-
:href="issue.url"
44+
:href="issue.html_url"
4445
target="_blank">
4546
<span class="has-color-forest-green">
4647
{{ issue.repo }}#{{ issue.number }}
@@ -70,8 +71,7 @@ export const IssueCard = {
7071
},
7172
computed: {
7273
dateCreated() {
73-
const dateCreated = new Date(this.issue.createdAt * 1000)
74-
const [dateComponent,] = dateCreated.toISOString().split("T")
74+
const [dateComponent,] = this.issue.created_at.split("T")
7575
return dateComponent
7676
}
7777
}
@@ -158,7 +158,7 @@ export const App = {
158158
* @returns {array} the array of filtered issues
159159
*/
160160
filteredIssues() {
161-
return window.issues.filter(issue => {
161+
return this.issues.filter(issue => {
162162
// Check experience match
163163
if (this.filters.experience === 'beginner' && !issue.labels.includes('good first issue')) {
164164
return false
@@ -178,6 +178,20 @@ export const App = {
178178
const BASE_URL = 'https://raw.githubusercontent.com/creativecommons/ccos-scripts/master/normalize_repos'
179179
const FILE_URL = name => `${BASE_URL}/${name}.json`
180180

181+
const octokit = new Octokit();
182+
octokit.search.issuesAndPullRequests({
183+
q: 'org:creativecommons is:open is:issue label:"help wanted"',
184+
per_page: 100
185+
}).then(res => {
186+
this.issues = res.data.items
187+
this.issues.forEach(issue => {
188+
issue.labels = issue.labels.map(label => label.name)
189+
190+
const repoUrl = issue.repository_url
191+
issue.repo = repoUrl.slice(repoUrl.lastIndexOf('/')+1)
192+
})
193+
})
194+
181195
Promise
182196
.all([
183197
fetch(FILE_URL('skills'))

0 commit comments

Comments
 (0)