Skip to content
This repository has been archived by the owner on Jun 5, 2020. It is now read-only.

Set a flag when a user has viewed an activity. #20

Open
hadees opened this issue Sep 29, 2012 · 4 comments
Open

Set a flag when a user has viewed an activity. #20

hadees opened this issue Sep 29, 2012 · 4 comments

Comments

@hadees
Copy link
Contributor

hadees commented Sep 29, 2012

I've noticed that streama does a pretty good job acting as a way of displaying notifications to users. The issue i'm running into is that I can't tell a user what notifications are new or not because I'm not tracking when they viewed them. I started writing a simple patch for this but I quickly realized it didn't make sense because users share activities models. So i'm open to suggestions on how best to do this. Would you even accept a patch?

I've also being thinking how hard it would be to allow a model to use streama twice. So a user model could have Activity and Notification.

@christospappas
Copy link
Owner

This is definitely a good idea, patches are welcome.

It would be a lot easier to do this if every user had their own copy of an activity but then it gets a little messy as we cache data and any change has to run through potentially hundreds of documents.

There is a fork from joe1chen that does this if you'd like to look at it.

I'm open to any ideas you have on how to make this work...

@hadees
Copy link
Contributor Author

hadees commented Sep 29, 2012

So I see a few options on how to do it but the only one that really makes any sense is to add a viewed_at key into the receiver hash.

I'm not sure that is exactly elegant because you create that hash inside the publish method. Maybe receiver should be an embedded document?

After that I would just add some options to stream_for to only return unviewed activities. The downside with this though is you filter out the receivers array in the results so I don't think we'd be able to check if an activity is viewed or not once we returned them. I'd really like to figure out a way to be able to check activities directly. Maybe don't filter out the receivers?

Then we just need a viewed! method that takes in an array of receivers and that'll set the viewed_at timestamp.

What are your feelings on this approach?

@hadees
Copy link
Contributor Author

hadees commented Oct 19, 2012

Any other ideas? I'm wondering if I should just fork streama into a gem that specifically deals with the notification use case but I'm not sure they are really that different. Other then the main fact a notification only has one receiver and needs to track if it was viewed.

I guess I could build a gem on top of streama that just adds that.

@christospappas
Copy link
Owner

Hi Evan,

Your approach of adding a viewed method to the receivers hash is a good idea and would solve your problem. An embedded document for each receiver will make it easier to access/modify but i'd have to look into the limitations with this.

Unfortunately I'm a little tied up with work at the moment to look into this in detail but if you create a fork i'll be happy to either merge your changes or promote it as an alternative.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants