If I were to implement what you have outlined, this is what I would do: *# Per 1 & 2*
I personally wouldn't not use a cronjob. While it can work, it's the wrong tool for the job. You should create jobs and have workers take care of these things. Using sidekiq & redis (or postgresql with queue classic) would take minimal effort with a lot of gain. It's also the write tool for the job. :) *#1* When the user starts the timer, send a request (ajax or whatnot) to the server to create a new job that is is scheduled at the expired time, based on when the timer started and how much time the timer was set for. The job should be to deliver the email you want to send. *#2* This should also be job that is scheduled to run every week. There are multiple ways to "schedule every week". The job can then handle the creation of the report and the sending of it. Hopefully this gives you something else to chew on. Robert On Sunday, October 12, 2014 10:05:14 AM UTC-7, Andrew Haines 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] 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.
