Thanks for the reply John. I would be stoked to have "too many users". I'll deal with it when it happens. 37 Signals - "Don't solve problems you don't have."
Drew On Sunday, October 12, 2014 11:45:47 AM UTC-7, John Lynch wrote: > > Drew, I agree with Chris that the cron job is perfectly fine. However, I > would not key off the start time in the database, instead when the user > starts a timer, store the start time AND the max end time, taking into > account the user’s preferences for maximum duration. Then, you just need > one SQL query to find all expired timers for all users and just batch send > all the emails. Now, if your site becomes *webscale*, then you will need > more complex architecture to keep things humming, but those are the kind of > problems we entrepreneurs pray for! > > -- > Regards, > > John Lynch > [email protected] <javascript:> > > > > > > On Sun, Oct 12, 2014 at 10:05 AM, Andrew Haines <[email protected] > <javascript:>> wrote: > >> Hi everyone, >> >> This is Drew Haines from DevCo <http://dmdevco.com/>. I am working on a >> web app called HoursLogger.com and want a second opinion on how to >> automate the emails for my Rails app. >> >> >> Hours Logger is a time tracking applications and currently sends 2 >> automated emails: >> 1. When a user's timer runs too long, it sends an email fix their >> timer >> 2. At the end of the week, it emails the user their weekly report >> >> >> *1. Timer Runs Too Long* >> Currently, the timer application runs on the client side. When the timer >> runs over the set time limit, an AJAX request is sent to the server to send >> the email. This is a problem because the app has to be open in the user's >> browser to fire the email, which isn't that helpful. So ... I need a way >> to track when a user's timer goes over their limit, *on the server*. >> >> I was thinking implement with cron job. >> - When a user starts the timer, use AJAX to save the start time in >> the database >> - Run a cron job that checks if any users have a start time, but no >> stop time >> - If they do, see if (now - time started) is longer than their limit >> - Send the email >> >> I am pretty sure I can make this work but is it a waste of resources? >> I would need a cron job constantly (every 5 minutes) monitor user's >> start and stop times. >> Is there a better way to implement? >> >> >> *2. Weekly Report* >> Cron job for sure on the weekly report. >> >> >> If you agree/ disagree please tell me. I wanted to kick around ideas >> with others on the community because 2 heads are better than 1. ( And an >> internet forum is even better than that! ) >> >> I appreciate any comments. >> Drew Haines >> >> >> >> -- >> -- >> SD Ruby mailing list >> [email protected] <javascript:> >> http://groups.google.com/group/sdruby >> --- >> You received this message because you are subscribed to the Google Groups >> "SD Ruby" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to [email protected] <javascript:>. >> For more options, visit https://groups.google.com/d/optout. >> > > -- -- SD Ruby mailing list [email protected] http://groups.google.com/group/sdruby --- You received this message because you are subscribed to the Google Groups "SD Ruby" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
