Looking for advice on how to fetch/load an onboarding banner

I'm using T3 inside a monorepo (turbo repo). For new users, I have a Get Started page that has a handful of checklist items. These checklist items are fetched from my database and ensure the user has finished the onboarding process. If there are still steps remaining, there is a banner at the top of the page alerting the user to finish their onboarding steps. My Question: Does anyone have any suggestions on how I can structure this so I'm not constantly running this query? Because right now, even if the user has completed all the steps, the app will still query and check to make sure all the items are complete. This in practice is good even after the user is finished onboarding because I want the banner to reappear if they delete their payment method or something. Can this be 'lazy queried' (not sure if that's a thing) or maybe run in middleware or something to where it would have minimal impact on the performance? Or maybe I'm overthinking this and I should just keep it as is? But in general I'm getting the feeling that I am running unnecessary queries and there is a better way to handle the logic here. Thanks for the help!
6 Replies
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
JulieCezar
JulieCezar2y ago
I think you are overthinking this xD However, maybe a little improvement would be to do the querying inside a component where you set the stale time to infinity. In that way you wont get queries until the page is refreshed. You could even go further than this, but then you would lose on the "... I want the banner to reappear if they delete their payment method..."
cje
cje2y ago
How expensive is this query?
JJ Rise
JJ Rise2y ago
yeah I set the stale time and cache times to be more appropriate. They aren't the aggressive defaults anymore. correct, but the consideration is not whether or not it has to run, but if there are steps to optimize. For example, changing cache and stale times was a good suggestion. yeah that's a great thought... i adjusted the cache and stale times now. But you're correct, if I seemingly go any further I lose the ability to maintain the banner for compliance (payment methods, etc)
JulieCezar
JulieCezar2y ago
This is a "trap" I find myself falling into quite often... In the sense that you try to optimize something to perfection when its not really necessary
JJ Rise
JJ Rise2y ago
makes sense, thanks for the insight
Want results from more Discord servers?
Add your server