Compare commits

...

6 Commits

Author SHA1 Message Date
keyan
1d154ec9b5 attempt to fix lastChecked getting overwritten 2024-04-06 18:28:23 -05:00
keyan
1f466970b3 disallow referring self 2024-04-06 13:46:18 -05:00
keyan
3472670df5 add clientside fetch delay 2024-04-06 10:38:54 -05:00
keyan
9b98843541 fix Sub.createdAt -> Sub.created_at generically 2024-04-05 19:24:31 -05:00
ekzyis
0b07962e1c
Fix 404 for territories in profile (#1029) 2024-04-05 14:47:05 -05:00
ekzyis
ba8b37ffb9
Add missing space in front of founding date (#1027) 2024-04-05 11:52:11 -05:00
5 changed files with 15 additions and 5 deletions

View File

@ -186,6 +186,7 @@ export default {
const subs = await models.$queryRawUnsafe(` const subs = await models.$queryRawUnsafe(`
SELECT "Sub".*, SELECT "Sub".*,
"Sub".created_at as "createdAt",
COALESCE(floor(sum(msats_revenue)/1000), 0) as revenue, COALESCE(floor(sum(msats_revenue)/1000), 0) as revenue,
COALESCE(floor(sum(msats_stacked)/1000), 0) as stacked, COALESCE(floor(sum(msats_stacked)/1000), 0) as stacked,
COALESCE(floor(sum(msats_spent)/1000), 0) as spent, COALESCE(floor(sum(msats_spent)/1000), 0) as spent,
@ -394,7 +395,8 @@ export default {
}, },
meSubscription: async (sub, args, { me, models }) => { meSubscription: async (sub, args, { me, models }) => {
return sub.meSubscription || sub.SubSubscription?.length > 0 return sub.meSubscription || sub.SubSubscription?.length > 0
} },
createdAt: sub => sub.createdAt || sub.created_at
} }
} }

View File

@ -516,8 +516,15 @@ export default function Notifications ({ ssrData }) {
const router = useRouter() const router = useRouter()
const dat = useData(data, ssrData) const dat = useData(data, ssrData)
const { notifications: { notifications, lastChecked, cursor } } = useMemo(() => { const { notifications, lastChecked, cursor } = useMemo(() => {
return dat || { notifications: {} } if (!dat?.notifications) return {}
// make sure we're using the oldest lastChecked we've seen
const retDat = { ...dat.notifications }
if (ssrData?.notifications?.lastChecked < retDat.lastChecked) {
retDat.lastChecked = ssrData.notifications.lastChecked
}
return retDat
}, [dat]) }, [dat])
useEffect(() => { useEffect(() => {

View File

@ -43,7 +43,7 @@ export function TerritoryInfo ({ sub }) {
<Link href={`/${sub.user.name}`}> <Link href={`/${sub.user.name}`}>
@{sub.user.name}<span> </span><Hat className='fill-grey' user={sub.user} height={12} width={12} /> @{sub.user.name}<span> </span><Hat className='fill-grey' user={sub.user} height={12} width={12} />
</Link> </Link>
<span>on </span> <span> on </span>
<span className='fw-bold'>{new Date(sub.createdAt).toDateString()}</span> <span className='fw-bold'>{new Date(sub.createdAt).toDateString()}</span>
</div> </div>
<div className='text-muted'> <div className='text-muted'>

View File

@ -220,6 +220,7 @@ function getClient (uri) {
} }
}), }),
assumeImmutableResults: true, assumeImmutableResults: true,
queryDeduplication: true,
defaultOptions: { defaultOptions: {
watchQuery: { watchQuery: {
initialFetchPolicy: defaultFetchPolicy, initialFetchPolicy: defaultFetchPolicy,

View File

@ -57,7 +57,7 @@ function getCallbacks (req) {
// this means users can update their referrer if they don't have one, which is fine // this means users can update their referrer if they don't have one, which is fine
if (req.cookies.sn_referrer && user?.id) { if (req.cookies.sn_referrer && user?.id) {
const referrer = await prisma.user.findUnique({ where: { name: req.cookies.sn_referrer } }) const referrer = await prisma.user.findUnique({ where: { name: req.cookies.sn_referrer } })
if (referrer) { if (referrer && referrer.id !== Number(user.id)) {
await prisma.user.updateMany({ where: { id: user.id, referrerId: null }, data: { referrerId: referrer.id } }) await prisma.user.updateMany({ where: { id: user.id, referrerId: null }, data: { referrerId: referrer.id } })
notifyReferral(referrer.id) notifyReferral(referrer.id)
} }