handle some rewards corner cases
This commit is contained in:
parent
9a4476b1fe
commit
faf71f744c
|
@ -16,6 +16,9 @@ export default {
|
|||
throw new GraphQLError('invalid date', { extensions: { code: 'BAD_USER_INPUT' } })
|
||||
}
|
||||
})
|
||||
if (new Date(when[0]) > new Date(when[when.length - 1])) {
|
||||
throw new GraphQLError('bad date range', { extensions: { code: 'BAD_USER_INPUT' } })
|
||||
}
|
||||
}
|
||||
|
||||
const results = await models.$queryRaw`
|
||||
|
@ -59,7 +62,7 @@ export default {
|
|||
GROUP BY days_cte.day
|
||||
ORDER BY days_cte.day ASC`
|
||||
|
||||
return results.length ? results : [{ total: 0, time: 0, sources: [] }]
|
||||
return results.length ? results : [{ total: 0, time: '0', sources: [] }]
|
||||
},
|
||||
meRewards: async (parent, { when }, { me, models }) => {
|
||||
if (!me) {
|
||||
|
|
|
@ -93,10 +93,14 @@ export function getGetServerSideProps ({ query, variables, notFound, authRequire
|
|||
|
||||
let error = null; let data = null; let props = {}
|
||||
if (query) {
|
||||
({ error, data } = await client.query({
|
||||
query,
|
||||
variables: vars
|
||||
}))
|
||||
try {
|
||||
({ error, data } = await client.query({
|
||||
query,
|
||||
variables: vars
|
||||
}))
|
||||
} catch (e) {
|
||||
console.error(e)
|
||||
}
|
||||
|
||||
if (error || !data || (notFound && notFound(data, vars))) {
|
||||
return {
|
||||
|
|
|
@ -172,9 +172,10 @@ function EarnNotification ({ n }) {
|
|||
{n.sources.tipPosts > 0 && <span>{(n.sources.comments > 0 || n.sources.posts > 0) && ' \\ '}{numWithUnits(n.sources.tipPosts, { abbreviate: false })} for zapping top posts early</span>}
|
||||
{n.sources.tipComments > 0 && <span>{(n.sources.comments > 0 || n.sources.posts > 0 || n.sources.tipPosts > 0) && ' \\ '}{numWithUnits(n.sources.tipComments, { abbreviate: false })} for zapping top comments early</span>}
|
||||
</div>}
|
||||
<div className='pb-1' style={{ lineHeight: '140%' }}>
|
||||
<div style={{ lineHeight: '140%' }}>
|
||||
SN distributes the sats it earns back to its best stackers daily. These sats come from <Link href='/~jobs'>jobs</Link>, boosts, posting fees, and donations. You can see the daily rewards pool and make a donation <Link href='/rewards'>here</Link>.
|
||||
</div>
|
||||
<small className='text-muted ms-1 pb-1 fw-normal'>click for details</small>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
|
|
Loading…
Reference in New Issue