Grasia / teem

Teem is a web tool and mobile app for collaboration in communities, which facilitates onboarding of newcomers
http://teem.works/
GNU Affero General Public License v3.0
49 stars 25 forks source link

Update user project and communities number #170

Closed atfornes closed 8 years ago

atfornes commented 8 years ago

The number of projects and communities in which a user participates is not updated on project and community join/leave

atfornes commented 8 years ago

@llopv and @atd, please check this commit https://github.com/P2Pvalue/teem/commit/7c1273ef6a62a7a351be62846482121c164a1e71 and tell me what you think... I have mixed feelings about it, but it is the best way I cold imagine to avoid lots of calls to SwellRT queries. Other solution is to refresh project and communities counters on each page change or other meaningful events...

atd commented 8 years ago

@atfornes I would like to talk this more in depth. We have an architectural flaw, from the relational database point of view. We are storing those references in the project side, when in a relational model there should be a join table for the N:N relation (user-project). But we are using a document database approach, and I am not sure how these things are managed in that paradigm. Maybe storing references to projectIds in the user (profile) side?

atfornes commented 8 years ago

Yes, we need to target the issue in a better way... To duplicate information in user profile is a possible source of errors, for instance, if somebody kick you out of a project and cannot (actually should not be able) modify your profile. A good way to deal with it is with the queries, but those are not real time and if the query is done just after the change, you will miss some changes...

I would like to know @pablojan opinion on this as well.

While we think about this problems, this commit solves the issue, If there are no big problems with it, I would pull it into master. What do you think?

atd commented 8 years ago

I find it a good hack, I made some comments but it LGTM

llopv commented 8 years ago

Meteor has reactive queries. If something is changed in the database, Meteor notifies all the clients who are subscribed to these changes [1] [2].

If we had this kind of technology in SwellRT, we wouldn't have to do these hacks, and everything (lists, counts...) would be updated in real-time. What do you think about it, @pablojan? Has it any sense for you?

atfornes commented 8 years ago

nice @llopv! I would love to see those reactive queires it in SwellRT :smile:

pablojan commented 8 years ago

SwellRT is only reactive for documents/waves, so it should provide a document/wave for each profile to cover that need. It would be a special document/wave only accesible by the user and updated by the server in case of some events as you mention (leave or join another document).

In general, many-to-many relationships between documents must be handled with lists en each side of the relationship :D

2016-03-17 12:33 GMT+01:00 David Llop notifications@github.com:

Meteor has reactive queries. If something is changed in the database, Meteor notifies all the clients who are subscribed to these changes [1] http://es.discovermeteor.com/chapters/publications-and-subscriptions/ [2] http://es.discovermeteor.com/chapters/reactivity/.

If we had this kind of technology in SwellRT, we wouldn't have to do these hacks, and everything (lists, counts...) would be updated in real-time. What do you think about it, @pablojan https://github.com/pablojan? Has it any sense for you?

— You are receiving this because you were mentioned. Reply to this email directly or view it on GitHub https://github.com/P2Pvalue/teem/issues/170#issuecomment-197836712

atfornes commented 8 years ago

In general, many-to-many relationships between documents must be handled with lists en each side of the relationship :D

Thanks @pablojan, it is also the solution proposed by @atd. How shoul we deal with one document dropping a relation but the other keeping it? do you have any nice reference on non-relational databases you can share with us?

Thanks!

llopv commented 8 years ago

SwellRT is only reactive for documents/waves, so it should provide a document/wave for each profile to cover that need. It would be a special document/wave only accesible by the user and updated by the server in case of some events as you mention (leave or join another document).

@pablojan This wave should not be only accessible from it's user, because we need this info also public in the profile view.

And what about doing any query reactive? I imagine a query to get all the projects that have the labels "democracy" and "computer science", returned as JSON in a special wave, and when a new project is added/removed or one of those tags is added/removed to a project, the wave is updated. Does it sound crazy for you?

atd commented 8 years ago

IMO reactive queries would be an awesome feature for SwellRT :smile:

pablojan commented 8 years ago

Sorry, but they are absolutly out of scope. The effort is not worth

2016-03-18 10:04 GMT+01:00 Antonio Tapiador notifications@github.com:

IMO reactive queries would be an awesome feature for SwellRT [image: :smile:]

— You are receiving this because you were mentioned. Reply to this email directly or view it on GitHub https://github.com/P2Pvalue/teem/issues/170#issuecomment-198266004

atfornes commented 8 years ago

I understand @pablojan, but I agree with @atd and @llopv :smile: