Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#839: Don't show 0 counts for top submitters #845

Merged
merged 1 commit into from
May 30, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
198 changes: 107 additions & 91 deletions src/views/Home.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -85,90 +98,93 @@ const Home = (props) => {
<h5>Top Submitters</h5>
<Suspense fallback={<div>Loading...</div>}>
<Tabs id='top-submissions-tabs'>
<Tab eventKey='Weekly' title='Weekly' className='metriq-nav-tab'>
<div className='card'>
<SortingTable
columns={[
{
title: 'Name',
key: 'username',
width: 360
},
{
title: 'Rank',
key: 'rank',
width: 80
},
{
title: 'Submission Count',
key: 'submissionsCount',
width: 360
}
]}
data={topSubmitters.weekly}
key={Math.random()}
onRowClick={(record) => this.props.history.push('/User/' + record.id + '/Submissions')}
tableLayout='auto'
rowClassName='link'
/>
</div>
</Tab>
<Tab eventKey='Monthly' title='Monthly' className='metriq-nav-tab'>
<div className='card'>
<SortingTable
columns={[
{
title: 'Name',
key: 'username',
width: 360
},
{
title: 'Rank',
key: 'rank',
width: 80
},
{
title: 'Submission Count',
key: 'submissionsCount',
width: 360
}
]}
data={topSubmitters.monthly}
key={Math.random()}
onRowClick={(record) => this.props.history.push('/User/' + record.id + '/Submissions')}
tableLayout='auto'
rowClassName='link'
/>
</div>
</Tab>
<Tab eventKey='AllTime' title='All Time' className='metriq-nav-tab'>
<div className='card'>
<SortingTable
columns={[
{
title: 'Name',
key: 'username',
width: 360
},
{
title: 'Rank',
key: 'rank',
width: 80
},
{
title: 'Submission Count',
key: 'submissionsCount',
width: 360
}
]}
data={topSubmitters.allTime}
key={Math.random()}
onRowClick={(record) => this.props.history.push('/User/' + record.id + '/Submissions')}
tableLayout='auto'
rowClassName='link'
/>
</div>
</Tab>
{(topSubmitters.weekly.length > 0) &&
<Tab eventKey='Weekly' title='Weekly' className='metriq-nav-tab'>
<div className='card'>
<SortingTable
columns={[
{
title: 'Name',
key: 'username',
width: 360
},
{
title: 'Rank',
key: 'rank',
width: 80
},
{
title: 'Submission Count',
key: 'submissionsCount',
width: 360
}
]}
data={topSubmitters.weekly}
key={Math.random()}
onRowClick={(record) => this.props.history.push('/User/' + record.id + '/Submissions')}
tableLayout='auto'
rowClassName='link'
/>
</div>
</Tab>}
{(topSubmitters.monthly.length > 0) &&
<Tab eventKey='Monthly' title='Monthly' className='metriq-nav-tab'>
<div className='card'>
<SortingTable
columns={[
{
title: 'Name',
key: 'username',
width: 360
},
{
title: 'Rank',
key: 'rank',
width: 80
},
{
title: 'Submission Count',
key: 'submissionsCount',
width: 360
}
]}
data={topSubmitters.monthly}
key={Math.random()}
onRowClick={(record) => this.props.history.push('/User/' + record.id + '/Submissions')}
tableLayout='auto'
rowClassName='link'
/>
</div>
</Tab>}
{(topSubmitters.allTime.length > 0) &&
<Tab eventKey='AllTime' title='All Time' className='metriq-nav-tab'>
<div className='card'>
<SortingTable
columns={[
{
title: 'Name',
key: 'username',
width: 360
},
{
title: 'Rank',
key: 'rank',
width: 80
},
{
title: 'Submission Count',
key: 'submissionsCount',
width: 360
}
]}
data={topSubmitters.allTime}
key={Math.random()}
onRowClick={(record) => this.props.history.push('/User/' + record.id + '/Submissions')}
tableLayout='auto'
rowClassName='link'
/>
</div>
</Tab>}
</Tabs>
</Suspense>
<br />
Expand Down