Writing Cron Jobs Just Became Fun Again
Be sure to checkout convex.dev/c/wdc which is the sponsor of this video, and convex is the backend as a service I use for project planner ai. I highly recommend trying it out!
My Products
📖 ProjectPlannerAI: projectplannerai.com
🤖 IconGeneratorAI: icongeneratorai.com
📝 ThumbnailCritique: thumbnailcritique.com
Useful Links
💬 Discord: / discord
🔔 Newsletter: newsletter.webdevcody.com/
📁 GitHub: github.com/webdevcody
📺 Twitch: / webdevcody
🤖 Website: webdevcody.com
🐦 Twitter: / webdevcody
Пікірлер: 48
Stop reminding me that I need to finish my projects. Low key I like this feature A LOT. Keep pumping those amazing features!
@WebDevCody
Ай бұрын
Thanks man!
Grammar police but, The title of that email says "You're friendly reminder".. should be Your friendly reminder
@WebDevCody
Ай бұрын
Thanks! I’ll fix that when I get a chance 🤣
I've developed something similar using AWS Scheduler. It also provides a cron job and implements exponential backoff. Worked great as well!
@cas818028
Ай бұрын
Same
The way you implemented this is quite interesting, at first I thought whenver a user visits a plan I add a cron job to run after 7 days to remind the user and I cancel the previously added cron jobs, I think this way would be good to allow users to customize how often they want to be reminded, but as I have more and more active users this number of created cron jobs will blow up
Love these Convex project videos and I’m still working on rethinking my design process to fit into Convex. Have you done any videos regarding form submission with Convex? Coming from my current project of react hook forms, zod validation , and server actions with Prisma I’m curious what the best approach to form submission and validation is on the Convex end prior to data mutation functions? I validate forms on the front end, but I struggle with trusting the data received by my Convex mutation functions…, or am I overthinking things?
@WebDevCody
Ай бұрын
Depending on the data you save, you still may need to bring in zod to your convex mutation to verify a v.string() is in certain format, etc. I still use use form hook with zod for client side forms
Very nice workflow :O Is it possible to perform SSR query fetching without using client useQuery to reduce requests and revalidate with Next.js when necessary? btw. did Convex reduce its bandwidth in the free tier? :/
@WebDevCody
Ай бұрын
Yes convex has a method to fetch the data in a SSR RSC and pass it down as initial props to your useQuery
You could add the reminders enabled check to the db query to prevent having to filter those out in js. Should be slightly better in case there are a lot of plans that have a matching timestamp
@WebDevCody
Ай бұрын
Yeah that could help with db query performance, but feels like a premature optimization until I reach thousands of user projects.
@lakitu3624
Ай бұрын
Yeah that's fair enough
Wouldn't it make sense to query all the data at once. And send the emails in bulk (1000 batches)?
@WebDevCody
Ай бұрын
Absolutely 😅 I forgot resend has a resend.batch.send method. But, the api still has 10 requests per second rate limit, so even if sending batches of 100 (which is their max batch size), you’ll need to handle rate limiting the same approach
What happened to clean architecture pantry project
Small thing, your subject starts with "You're friendly reminder" when it should be "Your friendly reminder".
Why didn't you filter the plans by remindersEnabled right away in the query?
@WebDevCody
Ай бұрын
That’s an option. It sounds more like a premature optimization don’t you think?
Interesting. I have a small problem with this architecture though. I am sure that you considered the numbers for your particular case and this is fine, but this model doesn't scale. First of all, you query the database daily at 9am which potentially might return a very large result object. You load it entirely to memory and don't use pagination, but the probability that the projects become a lot, like over 1mil is out of the question so this is fine. But the second thing is the queue turnover time of 200ms to send emails. If you have a list of 10k projects that needs to be reminded (it is fair I guess) you are looking at a time of execution of your cron job of 2k seconds. Which is not too long (it's like 30 mins) but you get my point. My question in this case is why did you for an external service like Resend, when you could use a native nodemailer for instance, considering you are using your email to send emails?
@WebDevCody
Ай бұрын
These are all great points, but I’m not at scale so I don’t spend time architecting for scale. I will say resend has a bulk send method where I can batch 100 emails at a time which could help speed up this process. Using nodemailer would require setting up or using an existing smtp server (more time to setup) and using gmail to send emails has various limits in place. Sending from resend often gives higher guarantees that my emails will never go to junk mail and additionally they have a nice feature where I can send marketing emails directly to my users mailing list and has built in unsubscribing functionality.
@rodjenihm
Ай бұрын
When he has 10k customer he will be making enough money to hire Rust specialist to rewrite it scalable.
@WebDevCody
Ай бұрын
@@rodjenihm convex is written in rust, so I think I’m good on the api and database side of things
this is why i like Laravel too, so much is already there, ready for use 👍
i cant sign up on project planner ai with throwaays emails! why?? how can i check out the app??
@WebDevCody
Ай бұрын
make a throw away email on gmail instead of some random throw away email service
Awesome stuff!
Good job bub!!!❤
that thumbnail is funny af
Came to KZread to search best way to build email templates in React but decided to watch your video first, turns out…
A day without web dev cody videos is just a normal day 😝. Have you used SSEs in your project, i would love to see where you used them as i am getting some trouble while setting up in mine.
@WebDevCody
Ай бұрын
I’ve used them once a long time ago. Convex uses websockets for all the real-time updates, so the need to write SSE goes away
More convex tutorials please!
Small typo in your email: You're friendly reminder -> Your friendly reminder. GOod vid btw
@WebDevCody
Ай бұрын
Oppps thank you!
@Nurof3n_
Ай бұрын
@@WebDevCody also miniutes -> minutes
@alexandrepereira6522
Ай бұрын
@@WebDevCody Another typo "30 miniutes" a day
@WebDevCody
Ай бұрын
@@alexandrepereira6522 y’all are the best
What's that nice vs code theme?
@WebDevCody
Ай бұрын
Bearded theme stained blue