Archived
popglob
This commit is contained in:
+2
-2
@@ -67,7 +67,7 @@ low(new FileAsync(__dirname + '/db.json')) // production
|
||||
if (row.value()) {
|
||||
let tmpA = videos.filter(x => x.id !== req.query.id).map(x => {
|
||||
return {
|
||||
"videoId": x.id,
|
||||
"videoID": x.id,
|
||||
"timesWatched": x.timesWatched,
|
||||
"prevalentReason": x.reason.sort((a, b) => a.timesWatched - b.timesWatched).reverse()[0].reason,
|
||||
"lastSelected": x.lastWatched
|
||||
@@ -83,7 +83,7 @@ low(new FileAsync(__dirname + '/db.json')) // production
|
||||
else {
|
||||
let tmpA = videos.map(x => {
|
||||
return {
|
||||
"videoId": x.id,
|
||||
"videoID": x.id,
|
||||
"timesWatched": x.timesWatched,
|
||||
"prevalentReason": x.reason.sort((a, b) => a.timesWatched - b.timesWatched).reverse()[0].reason,
|
||||
"lastSelected": x.lastWatched
|
||||
|
||||
@@ -13,32 +13,21 @@ class popGlobaleAssoluta extends React.Component {
|
||||
};
|
||||
|
||||
componentDidMount() {
|
||||
// listSiti.map(
|
||||
// sito =>
|
||||
// axios.get(`http://site${sito}.tw.cs.unibo.it/globpop`, {
|
||||
// 'params': {
|
||||
// 'id': this.props.match.params.id
|
||||
// }
|
||||
// })
|
||||
// )
|
||||
|
||||
|
||||
// let listSiti = ['1828', '1829', '1838', '1839', '1846', '1822', '1847', '1831', '1827', '1848', '1824', '1830', '1836', '1850', '1849', '1851', '1861', '1823', '1863', '1834', '1904', '1906', '1901', '1862', '1859'];
|
||||
let listSiti = ['1828', '1838', '1839', '1846', '1831', '1827', '1849', '1823', '1863', '1834', '1901', '1859'];
|
||||
let axiosReq = [];
|
||||
for (let i = 0; i < listSiti.length; i++) {
|
||||
console.log(`http://site${listSiti[i]}.tw.cs.unibo.it/globpop`)
|
||||
axiosReq.push(axios.get(`http://site${listSiti[i]}.tw.cs.unibo.it/globpop`, {
|
||||
'params': {
|
||||
'id': this.props.match.params.id
|
||||
}
|
||||
}))
|
||||
}
|
||||
Promise.all(axiosReq)
|
||||
.then(axios.spread((...res) => {
|
||||
console.log(res.map(x => x.data))
|
||||
})
|
||||
let listSiti = ['1828', '1838', '1839'];
|
||||
Promise.all(
|
||||
listSiti.map(
|
||||
el => fetch(`http://site${el}.tw.cs.unibo.it/globpop?id=${this.props.match.params.id}`)
|
||||
.then(res =>
|
||||
res.json()
|
||||
)
|
||||
)
|
||||
).then(res => {
|
||||
/* do something with res here... */
|
||||
console.log(res)
|
||||
let tmp = res.map(x => x.recommended);
|
||||
let tmp2 = tmp.map(el => el.map(el1 => el1.videoID || el1.videoId) )
|
||||
});
|
||||
}
|
||||
|
||||
// METODI
|
||||
|
||||
Reference in New Issue
Block a user