mentorship-backend
mentorship-backend copied to clipboard
feat: user comment should provide also user display name and profile picture
Is your feature request related to a problem? Please describe. When we display comments we want to see who made the comment and see profile picture.
Describe the solution you'd like Add used node to comment which contains user display name and profile picture
Describe alternatives you've considered not nesting those values under user but it is less elegant or attaching all user information which is overwhelming
Additional context current json response looks as follows:
[
{
"id": 1,
"user_id": 2,
"task_id": 1,
"relation_id": 1,
"creation_date": 1581885745.451706,
"modification_date": null,
"comment": "test comment"
}
]
@isabelcosta can I work on this issue?
Sure @SanujBansal :)
@isabelcosta Is the issue available? I want to work on this
@isabelcosta can I work on this?
@jotharman lets me just know if anyone else that requested to work on this is working on it. @SanujBansal are you interested in working on this? If not please let us know so we can assign this to another contributor. cc @satya7289
Sure @isabelcosta
I can assign this to you @jotharman :) if you are not working on any other issue currently. Can you please confirm?
I am not working on any other issue presently :)
you are assigned ;) feel free to send a PR on it
Yeah Thank you @isabelcosta :))
@isabelcosta If we add additional fields of "name" and "photo_url" in the tasks_comments table, we would be violating the DRY principles. We have the user_id in the data which I think we can use for directly accessing these variables from the users' table in the frontend. Please correct me if I am wrong :)
@jotharman interesting point 🤓 Although, in the frontend, we don't have the user data like that. We don't have user data stored there. Here's something to have in consideration, comments within a task can be from at least 2 members (so not only the logged-in user, which we could have the details). If we want to show the user display name and picture in the frontend, we have to send that in the response from the backend. I don't see this as DRY problem in the code, but as adapting the REST API to accommodate needs on a specific UI.
Let me know what you think @jotharman 🤔 this is a good discussion to have :) I would even invite @annabauza to give input on this
@isabelcosta Can we access the data from 'users' table (in frontend)using the id of the user which we already have in the tasks_comments table? The way we are accessing the comment and user_id of the user stored in the tasks_comments table, we can get the name and photo_url of the same user using the user_id. I hope it make sense :)
@isabelcosta then should I go ahead with creating new fields(two columns "name" and "photo_url") in the table "tasks_comments" for accessing them directly?
@isabelcosta I have created the pull request for this issue. Can you please review the same?