@@ -93,12 +93,6 @@ export const App = {
93
93
label="name"
94
94
:reduce="experience => experience.code"
95
95
:clearable="false"/>
96
-
97
- <button
98
- class="button small is-success margin-top-small"
99
- @click.prevent="search">
100
- Search
101
- </button>
102
96
</form>
103
97
</div>
104
98
<div class="column">
@@ -137,70 +131,46 @@ export const App = {
137
131
}
138
132
} ,
139
133
computed : {
140
- /**
141
- * Get a nested list of all the labels to search for. This is only based on
142
- * the experience filter. The skills filter must be applied on the client
143
- * side due to limitations of the GitHub API.
144
- *
145
- * This returns a list of lists. Each nested list corresponds to a single
146
- * API query and multiple queries need to be run to get the combined set of
147
- * valid issues.
148
- *
149
- * @returns {array } the array of array of labels
150
- */
151
- labelsList ( ) {
152
- const labelsList = [ ]
153
- if ( this . filters . experience === 'experienced' ) {
154
- labelsList . push ( 'help wanted' )
155
- } else {
156
- labelsList . push ( 'good first issue' )
157
- }
158
- return labelsList
159
- } ,
160
134
/**
161
135
* Get a filtered list of issues matching the chosen skill labels.
162
136
*
163
137
* @returns {array } the array of filtered issues
164
138
*/
165
139
filteredIssues ( ) {
166
- let filtered = this . issues
167
- if ( this . filters . skills . length ) {
168
- filtered = filtered . filter ( issue => {
169
- const joinedLabels = issue . labelNames . join ( ',' )
170
- return this . filters . skills . some ( skill => joinedLabels . includes ( skill ) )
171
- } )
172
- }
173
- return filtered
140
+ return this . issues . filter ( issue => {
141
+ const joinedLabels = issue . labelNames . join ( ',' )
142
+ if ( this . filters . skills . length && ! this . filters . skills . some ( skill => joinedLabels . includes ( skill ) ) ) {
143
+ return false
144
+ }
145
+ if ( this . filters . experience === 'beginner' && ! joinedLabels . includes ( 'good first issue' ) ) {
146
+ return false
147
+ }
148
+ return true
149
+ } )
174
150
}
175
151
} ,
176
152
methods : {
177
153
/**
178
- * Get a Promise for the list of issues pertaining to a given labels.
154
+ * Run the search based on the data submitted via the form and load all
155
+ * results into the `issues` attribute. Can be reused for a future
156
+ * 'Load More' button.
179
157
*
180
- * @param {Array } labels - list of labels to search for
181
- * @returns {Promise } a promise that resolves into a list of issues
158
+ * @param {number } page - the page of results to fetch
182
159
*/
183
- promise ( labels = [ ] ) {
184
- const params = {
185
- org : 'creativecommons' ,
186
- state : 'open' ,
187
- filter : 'all' ,
188
- per_page : 200
189
- }
190
- if ( labels ) {
191
- params . labels = labels . join ( ',' )
192
- }
193
- return octokit
160
+ search ( page = 1 ) {
161
+ octokit
194
162
. issues
195
- . listForOrg ( params )
163
+ . listForOrg ( {
164
+ org : 'creativecommons' ,
165
+ state : 'open' ,
166
+ filter : 'all' ,
167
+ labels : 'help wanted' ,
168
+ sort : 'created' ,
169
+ direction : 'desc' ,
170
+ per_page : 100 ,
171
+ page
172
+ } )
196
173
. then ( response => response . data )
197
- } ,
198
- /**
199
- * Run the search based on the data submitted via the form and load all
200
- * results into the `issues` attribute.
201
- */
202
- search ( ) {
203
- this . promise ( this . labelsList )
204
174
. then ( issueLists => {
205
175
const issues = issueLists . flat ( )
206
176
issues . forEach ( issue => {
0 commit comments