codeforboston / codeforboston/maple

Update Testimony Counts When Deleting Testimony

Open
#1,955 0 comments 0 reactions 1 assignee Claimed by @jasrose View on GitHub
backend enhancement good first issue Ready for Development Testimony Flow
Dominant language
TypeScript
Stars
56
Forks
175
Avg merge
2d 5h
Merged PRs (30d)
13

Description

## Problem

When an Admin deletes a reported testimony for a bill from the admin view, we want that bill's testimony counts (i.e. endore/neutral/oppose/total) to reflect the new totals. Currently, the testimony counts are not updated when deleting a testimony through the admin view. This is because we have two delete paths for deleting testimony - one in a Firebase function (that correctly updates counts on deletion) and one through an edge function in the Next.js API (that does not update counts). The admin page uses the latter.

## Success Criteria
- [ ] When deleting a reported testimony for a bill through the Admin page, that bill's testimony counts should be updated
- [ ] e.g. If a bill has 10 Endorse and 4 Oppose testimonies and one of the Endorse testimony is deleted, the bill should now have 9 Endore and 4 Oppose in its testimony counts.
- [ ] It *may* be prudent to unify the two testimony deletion paths for more consistent behavior going forward - given that deleting testimony tends to be an admin-facing process, I don't think the cold start latency concerns of the Firebase function should be considered a blocker (and it seems that the Firebase Function `deleteTestimony` is the more fully-featured path).

## Additional Notes
- The delete path the Admin page currently uses: https://github.com/codeforboston/maple/blob/1f36c588f86da91082f66d70e002bce0d8545ce1/components/api/delete-testimony.ts#L13
- The `deleteTestimony` firebase function (that has behavior to update testimony counts): https://github.com/codeforboston/maple/blob/1f36c588f86da91082f66d70e002bce0d8545ce1/functions/src/testimony/deleteTestimony.ts#L86
- You should be able to test this sufficiently by giving yourself admin permissions when running the backend locally in Docker by using the default admin account found in the Firebase Emulator UI's authentication tab. If you feel you need admin permissions on the deployed DEV site to fully test this, reach out in #maple-developers in Slack.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.