diff options
author | Florrie <towerofnix@gmail.com> | 2018-11-19 23:24:24 -0400 |
---|---|---|
committer | Florrie <towerofnix@gmail.com> | 2018-11-19 23:24:24 -0400 |
commit | 5c8ce1db7004f8b44762a497438def8ea3c87fb5 (patch) | |
tree | e236dcd038578decc6ca18fe9e72295d2ae231f9 | |
parent | 102254ee49a78464e67140b7cc4592105de8a547 (diff) |
Remove duplicates from explore-users
-rwxr-xr-x | index.js | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/index.js b/index.js index 24e8454..27552c9 100755 --- a/index.js +++ b/index.js @@ -317,8 +317,14 @@ const explore = { } const fetchResults = await Promise.all(['recent', 'trending', 'popular'].map(m => fetch(getUrl(m)).then(res => res.json()))) - console.log(fetchResults) const projects = fetchResults.reduce((acc, arr) => acc.concat(arr), []) + + // Dumb "remove duplicates" code incoming! + let authors = projects.map(project => project.author) + const seenUsernames = [] + authors = authors.filter( + ({ username: un }) => seenUsernames.includes(un) ? false : (seenUsernames.push(un), true)) + const selected = shuffle(projects).slice(0, 15) return selected.map(project => project.author) } |