remove leaderboard

This commit is contained in:
k00b 2025-03-26 11:40:08 -05:00
parent de7f96a3a4
commit 26a23ade92
3 changed files with 3 additions and 53 deletions

View File

@ -1,6 +1,5 @@
import { amountSchema, validateSchema } from '@/lib/validate' import { amountSchema, validateSchema } from '@/lib/validate'
import { getAd, getItem } from './item' import { getAd, getItem } from './item'
import { topUsers } from './user'
import performPaidAction from '../paidAction' import performPaidAction from '../paidAction'
import { GqlInputError } from '@/lib/error' import { GqlInputError } from '@/lib/error'
@ -152,13 +151,6 @@ export default {
} }
}, },
Rewards: { Rewards: {
leaderboard: async (parent, args, { models, ...context }) => {
// get to and from using postgres because it's easier to do there
const [{ to, from }] = await models.$queryRaw`
SELECT date_trunc('day', (now() AT TIME ZONE 'America/Chicago')) AT TIME ZONE 'America/Chicago' as from,
(date_trunc('day', (now() AT TIME ZONE 'America/Chicago')) AT TIME ZONE 'America/Chicago') + interval '1 day - 1 second' as to`
return await topUsers(parent, { when: 'custom', to: new Date(to).getTime().toString(), from: new Date(from).getTime().toString(), limit: 500 }, { models, ...context })
},
total: async (parent, args, { models }) => { total: async (parent, args, { models }) => {
if (!parent.total) { if (!parent.total) {
return 0 return 0

View File

@ -18,7 +18,6 @@ export default gql`
total: Int! total: Int!
time: Date! time: Date!
sources: [NameValue!]! sources: [NameValue!]!
leaderboard: UsersNullable
ad: Item ad: Item
} }

View File

@ -14,7 +14,6 @@ import dynamic from 'next/dynamic'
import { FAST_POLL_INTERVAL, SSR } from '@/lib/constants' import { FAST_POLL_INTERVAL, SSR } from '@/lib/constants'
import { useToast } from '@/components/toast' import { useToast } from '@/components/toast'
import { useLightning } from '@/components/lightning' import { useLightning } from '@/components/lightning'
import { ListUsers } from '@/components/user-list'
import { Col, Row } from 'react-bootstrap' import { Col, Row } from 'react-bootstrap'
import { useData } from '@/components/use-data' import { useData } from '@/components/use-data'
import { GrowthPieChartSkeleton } from '@/components/charts-skeletons' import { GrowthPieChartSkeleton } from '@/components/charts-skeletons'
@ -42,25 +41,6 @@ ${ITEM_FULL_FIELDS}
ad { ad {
...ItemFullFields ...ItemFullFields
} }
leaderboard {
users {
id
name
photoId
ncomments
nposts
proportion
optional {
streak
gunStreak
horseStreak
stacked
spent
referrals
}
}
}
} }
} }
` `
@ -98,14 +78,14 @@ export function RewardLine ({ total, time }) {
} }
export default function Rewards ({ ssrData }) { export default function Rewards ({ ssrData }) {
// only poll for updates to rewards and not leaderboard // only poll for updates to rewards
const { data: rewardsData } = useQuery( const { data: rewardsData } = useQuery(
REWARDS, REWARDS,
SSR ? {} : { pollInterval: FAST_POLL_INTERVAL, nextFetchPolicy: 'cache-and-network' }) SSR ? {} : { pollInterval: FAST_POLL_INTERVAL, nextFetchPolicy: 'cache-and-network' })
const { data } = useQuery(REWARDS_FULL) const { data } = useQuery(REWARDS_FULL)
const dat = useData(data, ssrData) const dat = useData(data, ssrData)
let { rewards: [{ total, sources, time, leaderboard, ad }] } = useMemo(() => { let { rewards: [{ total, sources, time, ad }] } = useMemo(() => {
return dat || { rewards: [{}] } return dat || { rewards: [{}] }
}, [dat]) }, [dat])
@ -117,20 +97,6 @@ export default function Rewards ({ ssrData }) {
if (!dat) return <PageLoading /> if (!dat) return <PageLoading />
function EstimatedReward ({ rank, user }) {
if (!user) return null
const referrerReward = Math.max(Math.floor(total * user.proportion * 0.2), 0)
const reward = Math.max(Math.floor(total * user.proportion) - referrerReward, 0)
return (
<div className='text-muted fst-italic'>
<small>
<span>estimated reward: {numWithUnits(reward)} <small className='fw-light'>(+ {numWithUnits(referrerReward)} to referrers)</small></span>
</small>
</div>
)
}
return ( return (
<Layout footerLinks> <Layout footerLinks>
{ad && {ad &&
@ -141,7 +107,7 @@ export default function Rewards ({ ssrData }) {
<ListItem item={ad} ad /> <ListItem item={ad} ad />
</div>} </div>}
<Row className='pb-3'> <Row className='pb-3'>
<Col lg={leaderboard?.users && 5}> <Col>
<div <div
className='d-flex flex-column sticky-lg-top py-5' className='d-flex flex-column sticky-lg-top py-5'
> >
@ -159,13 +125,6 @@ export default function Rewards ({ ssrData }) {
<DonateButton /> <DonateButton />
</div> </div>
</Col> </Col>
{leaderboard?.users &&
<Col lg={7}>
<h2 className='pt-5 text-center text-muted'>leaderboard</h2>
<div className='d-flex justify-content-center pt-4'>
<ListUsers users={leaderboard.users} rank Embellish={EstimatedReward} />
</div>
</Col>}
</Row> </Row>
</Layout> </Layout>
) )