diff --git a/src/views/Home.js b/src/views/Home.js index e9a1c813..d918794f 100644 --- a/src/views/Home.js +++ b/src/views/Home.js @@ -23,17 +23,30 @@ const Home = (props) => { axios.get(config.api.getUriPrefix() + '/user/topSubmitters') .then(res => { const tSubmitters = res.data.data - tSubmitters.allTime[0].rank = '🥇' - tSubmitters.allTime[1].rank = '🥈' - tSubmitters.allTime[2].rank = '🥉' - tSubmitters.monthly[0].rank = '🥇' - tSubmitters.monthly[1].rank = '🥈' - tSubmitters.monthly[2].rank = '🥉' tSubmitters.weekly[0].rank = '🥇' tSubmitters.weekly[1].rank = '🥈' tSubmitters.weekly[2].rank = '🥉' + tSubmitters.monthly[0].rank = '🥇' + tSubmitters.monthly[1].rank = '🥈' + tSubmitters.monthly[2].rank = '🥉' + tSubmitters.allTime[0].rank = '🥇' + tSubmitters.allTime[1].rank = '🥈' + tSubmitters.allTime[2].rank = '🥉' + + const ts = { weekly: [], monthly: [], allTime: [] } + for (let i = 0; i < 3; ++i) { + if (tSubmitters.weekly[i].submissionsCount > 0) { + ts.weekly.push(tSubmitters.weekly[i]) + } + if (tSubmitters.monthly[i].submissionsCount > 0) { + ts.monthly.push(tSubmitters.monthly[i]) + } + if (tSubmitters.allTime[i].submissionsCount > 0) { + ts.allTime.push(tSubmitters.allTime[i]) + } + } - setTopSubmitters(tSubmitters) + setTopSubmitters(ts) }) if (!props.tabKey) { @@ -85,90 +98,93 @@ const Home = (props) => {