From 5c8ce1db7004f8b44762a497438def8ea3c87fb5 Mon Sep 17 00:00:00 2001 From: Florrie Date: Mon, 19 Nov 2018 23:24:24 -0400 Subject: Remove duplicates from explore-users --- index.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) 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) } -- cgit 1.3.0-6-gf8a5