Quantcast

Is there a way to do this in Grails?

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

Is there a way to do this in Grails?

antoaravinth
Consider I have a Task class like this :

class Task {
     String title
     Date   assignedOn
}
Now the user can have many tasks. Now consider there are 8 tasks already assigned to userX. Now the manager(a special kind of user) is creating a 2 tasks to that userX, now I have totally 10 tasks of the userX. It is easy to display all the 10 tasks to that user.

But what I want is, I need a way to display only those 2 tasks to that userX assuming that the userX have already viewed those 8 tasks.

What are the ways I can use to do this? Any plugins available for this in grails?

Thanks in advance.
Ant's
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Is there a way to do this in Grails?

Igor Sinev
I am not sure if I got the question right but I hope this helps:

If you add a boolean field to your Task class like

    boolean viewed

then to display new items (assuming there are not too much of them)
and mark them as viewed after that the controller code should be like

    def newTasks = Task.findAllByViewed(false)
    newTasks.each {
        it.viewed = true
        it.save()
    }
    render(view: 'newTasks', model: [newTasks: newTasks])
    // or simply [newTasks: newTasks] if the view name follows the convention

I don't think there is a plugin that can immediately help you
because code like this is application specific (the status may
be stored as an Enum value instead of boolean and marking a task
as viewed could be done with ajax request on click or mouse hover)

Cheers,
  Igor Sinev

On Sat, Feb 18, 2012 at 1:44 PM, antoaravinth
<[hidden email]> wrote:

> Consider I have a Task class like this :
>
> class Task {
>     String title
>     Date   assignedOn
> }
> Now the user can have many tasks. Now consider there are 8 tasks already
> assigned to userX. Now the manager(a special kind of user) is creating a 2
> tasks to that userX, now I have totally 10 tasks of the userX. It is easy to
> display all the 10 tasks to that user.
>
> But what I want is, I need a way to display only those 2 tasks to that userX
> assuming that the userX have already viewed those 8 tasks.
>
> What are the ways I can use to do this? Any plugins available for this in
> grails?
>
> Thanks in advance.
>
> -----
> Ant's
> --
> View this message in context: http://grails.1312388.n4.nabble.com/Is-there-a-way-to-do-this-in-Grails-tp4399485p4399485.html
> Sent from the Grails - user mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
>    http://xircles.codehaus.org/manage_email
>
>

---------------------------------------------------------------------
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: Is there a way to do this in Grails?

antoaravinth
Thanks this is what I want. But as you have mentioned in your answer like this "(assuming there are not too much of them) ". Since i'm creating a management tool, is that cause a performance issue?
Ant's
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Is there a way to do this in Grails?

Igor Sinev
I suppose in production environment the corresponding DB table should
be indexed on task assignee and task status. This could be done with
GORM mapping definition
http://grails.org/doc/latest/guide/GORM.html#databaseIndices

However, if there is a dedicated DB Administrator in your project, you
will probably need to adopt to a provided DB schema rather than create
tables by yourself.

If you need to know more about how Grails works with DB I would
recommend reading a "GORM Gotchas" series of articles by Peter
Ledbrook http://blog.springsource.org/2010/06/23/gorm-gotchas-part-1/

--
Cheers,
 Igor Sinev


On Sat, Feb 18, 2012 at 2:36 PM, antoaravinth
<[hidden email]> wrote:

> Thanks this is what I want. But as you have mentioned in your answer like
> this "(assuming there are not too much of them) ". Since i'm creating a
> management tool, is that cause a performance issue?
>
> -----
> Ant's
> --
> View this message in context: http://grails.1312388.n4.nabble.com/Is-there-a-way-to-do-this-in-Grails-tp4399485p4399534.html
> Sent from the Grails - user mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
>    http://xircles.codehaus.org/manage_email
>
>

---------------------------------------------------------------------
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: Is there a way to do this in Grails?

antoaravinth
Thanks once again for your answer. But I didn't understand  fully why it should be indexed on task assignee and task status in DB. From my understanding if I use task assignee and task status as the index, the DB will be sorted or arranged based on these two values. Am I right?
Ant's
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Is there a way to do this in Grails?

smakela
Creating index is not going to arrange your whole database. It just creates "mapping" that allows you to search faster with these parameters.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Is there a way to do this in Grails?

antoaravinth
Thanks smakela and others for the answers.

Cheers,
Anto.
Ant's
Loading...