Archived
popglob
This commit is contained in:
+2
-2
@@ -67,7 +67,7 @@ low(new FileAsync(__dirname + '/db.json')) // production
|
|||||||
if (row.value()) {
|
if (row.value()) {
|
||||||
let tmpA = videos.filter(x => x.id !== req.query.id).map(x => {
|
let tmpA = videos.filter(x => x.id !== req.query.id).map(x => {
|
||||||
return {
|
return {
|
||||||
"videoId": x.id,
|
"videoID": x.id,
|
||||||
"timesWatched": x.timesWatched,
|
"timesWatched": x.timesWatched,
|
||||||
"prevalentReason": x.reason.sort((a, b) => a.timesWatched - b.timesWatched).reverse()[0].reason,
|
"prevalentReason": x.reason.sort((a, b) => a.timesWatched - b.timesWatched).reverse()[0].reason,
|
||||||
"lastSelected": x.lastWatched
|
"lastSelected": x.lastWatched
|
||||||
@@ -83,7 +83,7 @@ low(new FileAsync(__dirname + '/db.json')) // production
|
|||||||
else {
|
else {
|
||||||
let tmpA = videos.map(x => {
|
let tmpA = videos.map(x => {
|
||||||
return {
|
return {
|
||||||
"videoId": x.id,
|
"videoID": x.id,
|
||||||
"timesWatched": x.timesWatched,
|
"timesWatched": x.timesWatched,
|
||||||
"prevalentReason": x.reason.sort((a, b) => a.timesWatched - b.timesWatched).reverse()[0].reason,
|
"prevalentReason": x.reason.sort((a, b) => a.timesWatched - b.timesWatched).reverse()[0].reason,
|
||||||
"lastSelected": x.lastWatched
|
"lastSelected": x.lastWatched
|
||||||
|
|||||||
@@ -13,32 +13,21 @@ class popGlobaleAssoluta extends React.Component {
|
|||||||
};
|
};
|
||||||
|
|
||||||
componentDidMount() {
|
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', '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 listSiti = ['1828', '1838', '1839'];
|
||||||
let axiosReq = [];
|
Promise.all(
|
||||||
for (let i = 0; i < listSiti.length; i++) {
|
listSiti.map(
|
||||||
console.log(`http://site${listSiti[i]}.tw.cs.unibo.it/globpop`)
|
el => fetch(`http://site${el}.tw.cs.unibo.it/globpop?id=${this.props.match.params.id}`)
|
||||||
axiosReq.push(axios.get(`http://site${listSiti[i]}.tw.cs.unibo.it/globpop`, {
|
.then(res =>
|
||||||
'params': {
|
res.json()
|
||||||
'id': this.props.match.params.id
|
|
||||||
}
|
|
||||||
}))
|
|
||||||
}
|
|
||||||
Promise.all(axiosReq)
|
|
||||||
.then(axios.spread((...res) => {
|
|
||||||
console.log(res.map(x => x.data))
|
|
||||||
})
|
|
||||||
)
|
)
|
||||||
|
)
|
||||||
|
).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
|
// METODI
|
||||||
|
|||||||
Reference in New Issue
Block a user