mentorship-backend
mentorship-backend copied to clipboard
Improve GET (...)/comments response to include user.name and sent_by_me
Description
As a frontend developer, I need to have more information about the user who commented on a task, so that I can display information as the user's name.
The idea is to improve the response of POST (...)/comments API to provide user name
and sent_by_me
boolean.
Mocks
Instead of having:
{
"id": 0,
"user_id": 0,
"task_id": 0,
"relation_id": 0,
"creation_date": 0,
"modification_date": 0,
"comment": "string"
}
Have something like:
{
"id": 0,
"sent_by_me": true,
"user": {
"id": 0,
"name": "string"
},
"task_id": 0,
"relation_id": 0,
"creation_date": 0,
"modification_date": 0,
"comment": "string"
}
where author
is the person who commented.
Acceptance Criteria
Update [Required]
- [ ] Update the response
- [ ] Update and write new unit tests
Definition of Done
- [ ] All of the required items are completed.
- [x] Approval by 1 mentor.
Estimation
4 hours
@isabelcosta I would like to work on this issue.
@PrashanthPuneriya Are you available to work on this?
@vj-codes Yes!
@PrashanthPuneriya feel free to start working on this :)
@PrashanthPuneriya are you still working on this :) Do you need any help?
@isabelcosta I was quite busy until now. Would resume working on this issue and ping you whenever I need help :)
No problem, but It's best then to open this issue for other contributors and then you can come back to this if its still available @PrashanthPuneriya
@isabelcosta I would love to work on this. But I don't have much idea about this project. Could you give me some advice to get started?
@jhalak27 I would look at how other APIs are done and the API you are planning to change. The important part is the TaskCommentDAO, here you can modify the returns to include the data you want. For example, here https://github.com/anitab-org/mentorship-backend/blob/develop/app/api/dao/task_comment.py#L100 you see that the comments are being fetched, you need to get the name of the user using UserModel
and add that to each comment that is in the list.
Does this help?
@jhalak27 would you like to work on this? Isabel has given you a brief about this issue above:)
@vj-codes @isabelcosta as I am new to this project, it will take some time. Will that be okay?
@jhalak27 that is totally fine, just let us know when you are stuck. Please give us update within 3 days intervals, and we can help you.
@isabelcosta I am a bit confused about how to do this.
Do I need to make changes in the class TaskCommentModel
?
https://github.com/jhalak27/mentorship-backend/blob/b9ebc706ceca1aad88fe4561d896e3a06c2f8a78/app/database/models/task_comment.py#L41 Here do I need to change the json object as desired?
Could you explain a bit more?
It can also be considered to just add the user_name property instead of creating a new user object. That way, it won't be a breaking change for the frontend apps. However, that would be a small thing to fix on the frontend, and creating a user object as described in the description would be the more scalable option.
@yugantarjain I am still finding it a bit tough. What should I do?
@jhalak27 I am a bit busy, I will help you more in the next few days! Also, feel free to ask for help on Zulip so that other people can try to help you out :)
@yugantarjain I am still finding it a bit tough. What should I do?
Hi @jhalak27!
What exact problem are you facing? (I'm not a backend expert though) Also, sorry for the late reply, and thanks for working on the issue! Yeah, asking on Zulip would be nice.
@isabelcosta I am a bit confused about how to do this. Do I need to make changes in the
class TaskCommentModel
? https://github.com/jhalak27/mentorship-backend/blob/b9ebc706ceca1aad88fe4561d896e3a06c2f8a78/app/database/models/task_comment.py#L41 Here do I need to change the json object as desired?Could you explain a bit more?
Yes, adding a property (or the user object) around lines 23-29. And then the initializer will also have to be updated accordingly. I'm not a backend expert, but most probably a migration script will also have to be created. Good Resource
Hey @jhalak27 any updates on this issue?
It's bit hard for me. But I am trying to understand what all changes need to be done. I think it would be better if you could open this issue for other contributors!
@isabelcosta is this up for grabs? I would definitely like to give it a try !
Sure @shubhank-saxena :) Assigning you this issue. Happy coding!
Hi @PrashanthPuneriya ,
There is no activity on this issue. If this is available, I would like to work on this issue. I have one assigned issue which is resolved and I have created PR which is in review state.
Hi @PrashanthPuneriya ,
There is no activity on this issue. If this is available, I would like to work on this issue. I have one assigned issue which is resolved and I have created PR which is in review state.
@shubhank-saxena, Please let me know if you are still working on it.
Hey @Ashokrayal you can work on it.
Assigning @Ashokrayal :)
Hi @PrashanthPuneriya, @isabelcosta,
Can you please review this piece of code? I have not written testcases yet as I am not sure if this is right way to do it. link
Thanks
@Ashokrayal I don't have much idea about Flask-RestX but, I added a review(note:- I may be wrong). Also, I think it is better if you create a PR even though if the work isn't completed and ask for further clarifications.
Hi @PrashanthPuneriya ,
I have fixed the issue and raised the PR.
Thanks.
@isabelcosta looks like issue #1110 and this issue are trying to accomplish the same thing. Please have a look at it.