specify non-reward days better

This commit is contained in:
keyan 2024-03-31 14:21:08 -05:00
parent 1e3a836fbc
commit b12cf53630
2 changed files with 8 additions and 2 deletions

View File

@ -79,7 +79,12 @@ async function getRewards (when, models) {
throw new GraphQLError('bad date range', { extensions: { code: 'BAD_USER_INPUT' } }) throw new GraphQLError('bad date range', { extensions: { code: 'BAD_USER_INPUT' } })
} }
if (new Date(when[0]).getTime() >= new Date('2024-03-01').getTime()) { if (new Date(when[0]).getTime() > new Date('2024-03-01').getTime()) {
// after 3/1/2024, we reward monthly on the 1st
if (new Date(when[0]).getUTCDate() !== 1) {
throw new GraphQLError('invalid reward date', { extensions: { code: 'BAD_USER_INPUT' } })
}
return await getMonthlyRewards(when, models) return await getMonthlyRewards(when, models)
} }
} }

View File

@ -16,7 +16,8 @@ const GrowthPieChart = dynamic(() => import('@/components/charts').then(mod => m
}) })
export const getServerSideProps = getGetServerSideProps({ export const getServerSideProps = getGetServerSideProps({
query: ME_REWARDS query: ME_REWARDS,
notFound: (data, params) => data.rewards.reduce((a, r) => a || new Date(r.time) > new Date(), false)
}) })
export default function Rewards ({ ssrData }) { export default function Rewards ({ ssrData }) {