Arquisoft / viadeSpec

Viade Data Model Specification
https://arquisoft.github.io/viadeSpec/
MIT License
7 stars 1 forks source link

Issue with posting comments in routes. #33

Closed uo265363 closed 4 years ago

uo265363 commented 4 years ago

It has been said that the comments will be stored in the pod of the user who comments and the route file will have the URI of that comment, but the user commenting should only have read permissions on the route file so it's not possible to add that URI. I think the best solution is to have another file, where the other users have permission to add and read information, but not to change it, so comment URIs can be added there, this way the route file cannot be modified by other users and they can still post comments by adding the URI to the comment file associated with that route. The comments property in the route file should be changed from a list of URIs to a single URI pointing that comment file that contains the list of comments URIs. I propose to include inside viade/comments 2 new folders, myComments to store the files that were stored before (the comments done by the pod's user), in the viade/comments, and myRoutesComments, to store the files containing the comments URIs done to the routes of pod's user. So this way a route has 2 files, one for all the route data itself with only read permissions in viade/routes, and another one which has the comments data with post permissions (read and add new information) in viade/comments/myRoutesComments.

uo265363 commented 4 years ago

This change implies 2 things for jsonld applications:

luispc1998 commented 4 years ago

I'm currently editing the proposal to include this approach, since there were no complains about it.

luispc1998 commented 4 years ago

I've tested this approach and I am getting very high loading times to obtain all the comments. Thinking in an route with n comments, we should perform n petitions to the POD. I'm currently thinking that it may be better to put the comments (text, dateCreated) in the comments file linked with the route, where currently there are links to the comments files. I know that each comment will not be stored in its user's POD, but I don't know if there is a way of solving it with a good performance.

Have you managed to solve it? Because I believe that even with an asynchronous approach the comments will take really long to load.

Considering my suggestion, I have not tested it yet, but accessing a file and parsing it, it's taking me a few seconds. Thinking about permissions, the file has already write permissions for the external users that comment to write the link, so it wouldn't be necessary anything in that part.

uo265363 commented 4 years ago

I haven't tested the perfomance of loading multiple comments due to an issue with permissions. How are you managing permissions? I give append permissions to the file but I wasn't able to modify the file properly, I just could with the write permisions, but that's a problem, other users could modify the comments if we give write to that file. Have you found a way to post comments with only the read and append permisions in the comments file?

luispc1998 commented 4 years ago

It doesn't really make a difference if you give append permissions I think, because if so user could append data to corrupt the file, so in the end it would be the same risk I think. However I performed the test with my own pod, because I wanted to check the performance, and I found that it was pretty bad.

Using file client, my process was the following. I read the route file, parse it, read the comments file, parse it, and then for each id in the this file I read and parse the comment. I don't understand the times that I am getting either I'm providing them to you.

1 comment -> takes the same to load the route (3 sec) 2 comments -> 12 seconds 3 comments -> 30 seconds 4 comments -> 38 minutes (I am not kidding)

I was expecting a linear complexity, so I don't really know what happended. If you manage to solve this issue with your approach I am really interested on how could you did it. If you cannot get a good performance either, I believe that should move the comments to the file linked to the route, if so then we would always have 2 accesses to the POD, and that is for sure complexity O(0).

uo265363 commented 4 years ago

I haven't tested it yet but it's ok for us to do that change if it implies a considerable decrease of time to load. The disadvantage of doing that is that the user posting the comments can not delete his own comment (as long as you don't create a more complex system), have you thought of a solution for that? Are you not going to enable the user posting the comment to delete his comment?

luispc1998 commented 4 years ago

I'm aware of that. We should implemented something as done in SDI subject, the approach would be similar to what we are doing with mongoDB, that is an ID, and the author of the comment. However we will not be implementing the deleting functionality, at least for now. I'm going to try to implement the other approach and measure times. I'll keep you up to date.

luispc1998 commented 4 years ago

I have finished my implementation of my approach, I can confirm an inmense speedup. The route takes an almost time of 2 sec to load, with many comments. I will update soon the pull request to display this version with examples.

themrcesi commented 4 years ago

Hi there!

We are finishing our app and we have found one problem related to comments and we don´t know if it has already been solved.

Imagine this scenario:

  1. Pepe shares a route ("rutaDePrueba.jsonld") with Pepito and Pepita
  2. Now, Pepito posts a comment of the sharedRoute. Therefore, Pepito will create a file pepitoComment.jsonld in pepitoUri/viade/comments/myComments and add a reference to that comment in pepeUri/viade/routeComments/rutaDePrueba.jsonld. And Pepito will also give read permissions to Pepe in pepitoUri/viade/comments/myComments/pepitoComment.jsonld.
  3. Now, Pepita posts a comment of the sharedRoute. Therefore, Pepita will create a file pepitaComment.jsonld in pepitaUri/viade/comments/myComments and add a reference to that comment in pepeUri/viade/routeComments/rutaDePrueba.jsonld. And Pepita will also give read permissions to Pepe in pepitaUri/viade/comments/myComments/pepitaComment.jsonld.

Pepito should be able to read Pepita´s comment of Pepe´s route, and also Pepita should be able to read Pepito´s comment of Pepe´s route. However, none of them have permissions to read each other´s comments.

Is this scenario complained in the specification? If so, can you explain it please? Sorry if it has already been solved, but I don´t find where.

luispc1998 commented 4 years ago

It not your fault I have just noticed that in the specification it is not explained as finally decided in this issue. Let me explain here the current approach, I'll make a pull request to update that typo.

I've explained it before but I want it to be clear.

Each route file will have a comments file, the property "comments" will be a link to such a file, (that file will be created at the same time as the route, you may find the example of such a file in this repo) That file will have the same permissions as the route so the ones that you shared the routes with can update it with their comment. I proposed this approach since the one exposed in first place with the comments in each user pod was highly inefficient and we can get rid of your problem using it too.

Route.jsonlg - has a link to > routecomments.json

You will use the routeComments for the comment functionality.

This special files will be placed in the viade/comments folder. I'm sorry for the typo in the proposal. I hope that you understood the approach. :D

themrcesi commented 4 years ago

I think I got it: The route file will have a link to the routeCommentsFile and users will directly write the comments in that referenced file.

Thanks a lot!