Hi Jeff,

Depending on how you have the data stored, yes you should be able to  
something in SQL to make the search better.

Does each user just have one time of day assigned to them? If so, then you  
can just put a condition on the find query.

Something like user.reminder_time > start_range and user.reminder_time <  
end_range and let the DB do the grunt work for you.

If the user notification is something like 'every 4 hours' then you are  
may have to process each user individually to work out whether the current  
time fits that range. Or have a 'next_notification' col that you update  
each time you send a notification to that user. Then do the db query on  
the next_notification field.

Cheers
Simon

On Tue, 21 Oct 2008 10:33:11 +0800, Jeff Pritchard  
<[EMAIL PROTECTED]> wrote:

>
> OK, time to come clean.  Right now my app is doing something really
> cheesy.  The first step is alway admitting that you have a problem,
> right?
>
> So here's the deal.  One of the features of my app is that, based on
> some user settings, it is supposed to send out "reminder" emails at
> certain times of the day.  Each user has their own time settings for
> these reminders.
>
> Right now I have a background task that, once every 15 mins, looks at
> every gosh darn user and decides whether or not to send them a reminder.
> Once every 15 mins I hit every single user row in the database.
> brrrrrrr.  Yeah, I know, gives me the willies too.
>
> So is there some sort of a "best practice" established for how to do
> some caching/intelligent-scheduling to overcome this horrendous mis-use
> of the database?  Is there some sort of a plugin that would allow me to
> sort the database by that time-of-day column and intelligently find just
> those within a certain range of times?
>
> I'm very nearly an SQL virgin, so if this is painfully simple and I'm
> just a moron, be gentle.
>
> thanks,
> jp



--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to