Quantcast

Implementing a User Subscription model

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Implementing a User Subscription model

bhushan154
We have a requirement which needs to allow users to subscribe to reports at their desired day of week. Say for example I need a report to be mailed to me every monday, while another user can choose to have it sent every wednesday.

What is the methodology and best approach to implement this solution?

Thank you
Bhushan
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Implementing a User Subscription model

Gary Affonso
On May 9, 2012, at 3:15 AM, bhushan154 wrote:

> We have a requirement which needs to allow users to subscribe to reports at
> their desired day of week. Say for example I need a report to be mailed to
> me every monday, while another user can choose to have it sent every
> wednesday.
>
> What is the methodology and best approach to implement this solution?

That's a very broad question (and not terribly grails specific).  There are a lot of way to do this and the "right way" is going to depend on additional details.

You probably want a User domain object to represent your user.  You'll want a property on that object to represent the "notification day".  You can do that as a simple property (perhaps a Calendar.DAY_OF_WEEK) or even as a one-to-many association to a "NotificationDay" object.

In either case, creating the CRUD controllers/views is very simple.  Indeed, just create the domain object you think you'll want and do a

  grails generate-all UserDomainClass

to see an example of a controller and views to handle the crud.

For the mail-sending you can use the quartz/scheduling functionality to kick off code at regularly timed intervals.  In that code it's pretty simple to...

   // determine the day of the week from the current date

   // get all UserDomainClass that have a "notification" setting matching this day

   // for each class sending an email

HTH

- Gary
---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Implementing a User Subscription model

bhushan154
Thanks for your response Gary.

It's probably all we need. A table to store the day of week for notifications and a scheduled tasks that runs everyday to send out emails. And maybe if we have more than one type of report, save that info in the table as well.
Loading...