Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Note edit and delete #507

Merged
merged 5 commits into from
Jun 24, 2024
Merged

Note edit and delete #507

merged 5 commits into from
Jun 24, 2024

Conversation

RichGriff
Copy link
Collaborator

  • API now has a new endpoint for fetching a single comment as well as update and delete
  • Reworked the /comments/{assurance_case_id}/ endpoint to make this work with the above
  • Ability for a user to toggle whether they would like to edit the comment or not
  • Ability for a user to remove the comment

@RichGriff RichGriff requested a review from cptanalatriste June 23, 2024 17:38
@coveralls
Copy link

coveralls commented Jun 23, 2024

Pull Request Test Coverage Report for Build 9635296974

Details

  • 2 of 23 (8.7%) changed or added relevant lines in 1 file are covered.
  • 7 unchanged lines in 1 file lost coverage.
  • Overall coverage decreased (-0.9%) to 82.059%

Changes Missing Coverage Covered Lines Changed/Added Lines %
eap_backend/eap_api/views.py 2 23 8.7%
Files with Coverage Reduction New Missed Lines %
eap_backend/eap_api/views.py 7 61.9%
Totals Coverage Status
Change from base Build 9614951569: -0.9%
Covered Lines: 1363
Relevant Lines: 1661

💛 - Coveralls

@coveralls
Copy link

coveralls commented Jun 23, 2024

Pull Request Test Coverage Report for Build 9635298553

Details

  • 2 of 22 (9.09%) changed or added relevant lines in 1 file are covered.
  • 2 unchanged lines in 1 file lost coverage.
  • Overall coverage decreased (-0.9%) to 82.059%

Changes Missing Coverage Covered Lines Changed/Added Lines %
eap_backend/eap_api/views.py 2 22 9.09%
Files with Coverage Reduction New Missed Lines %
eap_backend/eap_api/views.py 2 61.9%
Totals Coverage Status
Change from base Build 9614951569: -0.9%
Covered Lines: 1363
Relevant Lines: 1661

💛 - Coveralls

@@ -21,11 +21,17 @@
views.property_claim_list,
name="property_claim_list",
),
# path(
# "comments/<int:assurance_case_id>/",
# views.comment_list,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove commented code

path(
"comments/<int:assurance_case_id>/",
"assurance_case/<int:assurance_case_id>/comments/",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Although I might disagree with the initial API design, I see it is important to keep in consistent with all the other resources: case_element_in_plural/ for listing/creation deletion where you can send the assurance_case_id via request parameters instead of via slug. Please adjust accordingly.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cptanalatriste do you mean changing assurance_case to assurance_cases ?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was thinking doing something similar to goals, another top-level case item attached to assurance case (see goal_list and goal_detail). In that style, we would have two resources: comments/ to handle case-level retrieve and creation and comments/<int:pk> for update, deletion and single-comment retrieval. Just to keep the same design over the whole API

@@ -1,7 +1,7 @@
# TODO(cgavidia): This should be handled via environment variables.
# NEXT_PUBLIC_API_URL=http://localhost:8000
NEXT_PUBLIC_API_URL=http://localhost:8000
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please do not merge this code into develop

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cptanalatriste good catch! Will switch this out, forgot that we had this in the repo.


//@ts-ignore
assuranceCase.comments.sort((a, b) => new Date(b.created_at) - new Date(a.created_at));

useEffect(() => {
//@ts-ignore
assuranceCase.comments.sort((a, b) => new Date(b.created_at) - new Date(a.created_at));
console.log('Comments', assuranceCase.comments)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove unnecessary logs

}

const updatedComments = assuranceCase.comments.filter((comment:any) => comment.id !== id)
console.log('Updated Comments', updatedComments)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Idem



@api_view(["GET", "PUT", "DELETE"])
def comment_detail(request, pk):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given that we're out of "crunch-mode", please at least at some unit tests for the new backend code. At least at the test_view level

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cptanalatriste this is where I was hoping you'd be able to help

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@RichGriff of course! I can add a couple of tests to the branch

Copy link
Collaborator

@cptanalatriste cptanalatriste left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only some minor requests

@RichGriff
Copy link
Collaborator Author

@cptanalatriste will work on what I can today on the same branch.

@coveralls
Copy link

coveralls commented Jun 24, 2024

Pull Request Test Coverage Report for Build 9646635937

Details

  • 2 of 22 (9.09%) changed or added relevant lines in 1 file are covered.
  • 2 unchanged lines in 1 file lost coverage.
  • Overall coverage decreased (-0.9%) to 82.059%

Changes Missing Coverage Covered Lines Changed/Added Lines %
eap_backend/eap_api/views.py 2 22 9.09%
Files with Coverage Reduction New Missed Lines %
eap_backend/eap_api/views.py 2 61.9%
Totals Coverage Status
Change from base Build 9614951569: -0.9%
Covered Lines: 1363
Relevant Lines: 1661

💛 - Coveralls

@coveralls
Copy link

coveralls commented Jun 24, 2024

Pull Request Test Coverage Report for Build 9646622294

Details

  • 2 of 22 (9.09%) changed or added relevant lines in 1 file are covered.
  • 2 unchanged lines in 1 file lost coverage.
  • Overall coverage decreased (-0.9%) to 82.059%

Changes Missing Coverage Covered Lines Changed/Added Lines %
eap_backend/eap_api/views.py 2 22 9.09%
Files with Coverage Reduction New Missed Lines %
eap_backend/eap_api/views.py 2 61.9%
Totals Coverage Status
Change from base Build 9614951569: -0.9%
Covered Lines: 1363
Relevant Lines: 1661

💛 - Coveralls

Copy link
Collaborator Author

@RichGriff RichGriff left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes made

@coveralls
Copy link

coveralls commented Jun 24, 2024

Pull Request Test Coverage Report for Build 9648535842

Warning: This coverage report may be inaccurate.

This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.

Details

  • 2 of 22 (9.09%) changed or added relevant lines in 1 file are covered.
  • 2 unchanged lines in 1 file lost coverage.
  • Overall coverage decreased (-0.2%) to 82.746%

Changes Missing Coverage Covered Lines Changed/Added Lines %
eap_backend/eap_api/views.py 2 22 9.09%
Files with Coverage Reduction New Missed Lines %
eap_backend/eap_api/views.py 2 63.62%
Totals Coverage Status
Change from base Build 9614951569: -0.2%
Covered Lines: 1386
Relevant Lines: 1675

💛 - Coveralls

@RichGriff RichGriff merged commit 6e5da00 into develop Jun 24, 2024
8 checks passed
@RichGriff RichGriff deleted the #467-updating-removing-notes branch June 24, 2024 16:04
serializer = CommentSerializer(data=request.data)
data = request.data.copy()
data["assurance_case_id"] = (
assurance_case_id # Ensure assurance_case_id is set in the data
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, this shouldn't be needed. Aren't you already sending the assurance case ID in the payload body?

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

Successfully merging this pull request may close these issues.

3 participants