Writing Cron Jobs Just Became Fun Again

Поділитися
Вставка
  • Опубліковано 23 кві 2024
  • 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

  • @anthonygg_
    @anthonygg_ Місяць тому +20

    Stop reminding me that I need to finish my projects. Low key I like this feature A LOT. Keep pumping those amazing features!

  • @koachbryan
    @koachbryan Місяць тому +10

    Grammar police but, The title of that email says "You're friendly reminder".. should be Your friendly reminder

    • @WebDevCody
      @WebDevCody  Місяць тому +7

      Thanks! I’ll fix that when I get a chance 🤣

  • @bastin.5854
    @bastin.5854 Місяць тому +2

    I've developed something similar using AWS Scheduler. It also provides a cron job and implements exponential backoff. Worked great as well!

  • @Stallion45
    @Stallion45 Місяць тому

    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
      @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

  • @yassinesafraoui
    @yassinesafraoui Місяць тому

    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

  • @lakitu3624
    @lakitu3624 Місяць тому +1

    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
      @WebDevCody  Місяць тому

      Yeah that could help with db query performance, but feels like a premature optimization until I reach thousands of user projects.

    • @lakitu3624
      @lakitu3624 Місяць тому

      Yeah that's fair enough

  • @feossandon
    @feossandon Місяць тому

    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
      @WebDevCody  Місяць тому

      Yes convex has a method to fetch the data in a SSR RSC and pass it down as initial props to your useQuery

  • @hazemturki
    @hazemturki Місяць тому +1

    Wouldn't it make sense to query all the data at once. And send the emails in bulk (1000 batches)?

    • @WebDevCody
      @WebDevCody  Місяць тому +3

      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

  • @marcoio8742
    @marcoio8742 Місяць тому

    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
      @WebDevCody  Місяць тому +2

      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
      @rodjenihm Місяць тому +1

      When he has 10k customer he will be making enough money to hire Rust specialist to rewrite it scalable.

    • @WebDevCody
      @WebDevCody  Місяць тому +3

      @@rodjenihm convex is written in rust, so I think I’m good on the api and database side of things

  • @jovanjevtic1620
    @jovanjevtic1620 Місяць тому

    Why didn't you filter the plans by remindersEnabled right away in the query?

    • @WebDevCody
      @WebDevCody  Місяць тому

      That’s an option. It sounds more like a premature optimization don’t you think?

  • @patolorde
    @patolorde Місяць тому

    What happened to clean architecture pantry project

  • @JohnFarrellDev
    @JohnFarrellDev Місяць тому

    Small thing, your subject starts with "You're friendly reminder" when it should be "Your friendly reminder".

  • @CookerSingh
    @CookerSingh Місяць тому

    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
      @WebDevCody  Місяць тому +1

      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

  • @sincethatmoment
    @sincethatmoment Місяць тому

    that thumbnail is funny af

  • @gilneyn.mathias1134
    @gilneyn.mathias1134 Місяць тому

    this is why i like Laravel too, so much is already there, ready for use 👍

  • @ESArnau
    @ESArnau Місяць тому +2

    Small typo in your email: You're friendly reminder -> Your friendly reminder. GOod vid btw

    • @WebDevCody
      @WebDevCody  Місяць тому +2

      Oppps thank you!

    • @Nurof3n_
      @Nurof3n_ Місяць тому +2

      @@WebDevCody also miniutes -> minutes

    • @alexandrepereira6522
      @alexandrepereira6522 Місяць тому

      @@WebDevCody Another typo "30 miniutes" a day

    • @WebDevCody
      @WebDevCody  Місяць тому

      @@alexandrepereira6522 y’all are the best

  • @Vicseverin
    @Vicseverin Місяць тому +1

    Came to UA-cam to search best way to build email templates in React but decided to watch your video first, turns out…

  • @oscdev
    @oscdev Місяць тому

    Awesome stuff!

  • @SeibertSwirl
    @SeibertSwirl Місяць тому

    Good job bub!!!❤

  • @fottymutunda6320
    @fottymutunda6320 Місяць тому +1

    What's that nice vs code theme?

    • @WebDevCody
      @WebDevCody  Місяць тому +1

      Bearded theme stained blue

  • @abdirahmann
    @abdirahmann Місяць тому

    i cant sign up on project planner ai with throwaays emails! why?? how can i check out the app??

    • @WebDevCody
      @WebDevCody  Місяць тому

      make a throw away email on gmail instead of some random throw away email service

  • @MrArod1207
    @MrArod1207 Місяць тому

    More convex tutorials please!