Skip to content

Commit 7015c35

Browse files
committed
feat: 🎸 Discard languagues without trending results
Use promises to filter languages than doesn't have trending results. BREAKING CHANGE: y Issues: 0
1 parent 33b1c44 commit 7015c35

File tree

1 file changed

+28
-3
lines changed

1 file changed

+28
-3
lines changed

‎src/components/languages.vue‎

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@
99
<div v-if="results.length && search && $zircle.getCurrentViewName() === 'languages--0'">
1010
<z-spot
1111

12-
v-for="(language, index) in results"
12+
v-for="(language, index) in wt"
1313
button
1414
:key="'lang' + index"
1515
:distance="60"
16-
:angle="-90 + (360 / results.length * index)"
16+
:angle="-90 + (360 / wt.length * index)"
1717
size="xs"
1818
class="test1 accent"
1919
:label="language.name"
@@ -75,6 +75,17 @@
7575
// :angle="(180 - (180 - ($zircle.getNumberOfPages() * 10))) / $zircle.getNumberOfPages() * ($zircle.getNumberOfPages() - index) + ((180 - (180 - (180 - ($zircle.getNumberOfPages() * 10)))) - ((180 - (180 - ($zircle.getNumberOfPages() * 10))) / $zircle.getNumberOfPages())) / 2"
7676
import state from '../store/state'
7777
import axios from 'axios'
78+
function fetchGalleries(results) {
79+
return Promise.all(results.map(record => {
80+
return axios.get('https://github-trending-api.now.sh/repositories?language=' + record.urlParam)
81+
})).then(gal => {
82+
var papa = gal.filter(function (el) {
83+
return el.data.length > 0
84+
})
85+
console.log(papa.map(a => a.data[0].language))
86+
return papa.map(a => a.data[0].language)
87+
})
88+
}
7889
export default {
7990
data () {
8091
return {
@@ -83,6 +94,7 @@ export default {
8394
other: [],
8495
results: [],
8596
query: '',
97+
wt: [],
8698
search: false,
8799
sharedState: state.$data
88100
}
@@ -105,14 +117,27 @@ export default {
105117
},
106118
methods: {
107119
searchLanguages (e) {
120+
var vm = this
108121
if (e !== '') {
109122
var input = e.toLowerCase()
110123
this.results = this.other.filter(function (el) {
111124
var data = el.name.toLowerCase()
112125
return data.indexOf(input) > -1
113126
}).slice(-8)
114-
// console.log(this.results)
127+
var papa = fetchGalleries(vm.results)
128+
papa.then(result => {
129+
vm.wt = result.map(a => {
130+
var url = a.toLowerCase().replace(' ', '-')
131+
return {
132+
name: a,
133+
urlParam: url
134+
}
135+
})
136+
//vm.wt = result
137+
})
138+
115139
this.query = e
140+
116141
} else {
117142
this.query = ''
118143
this.results = []

0 commit comments

Comments
 (0)