-
Notifications
You must be signed in to change notification settings - Fork 47
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
10455 Story: Add/Remove/Modify Judge Users #5264
Conversation
…from applicationContext
…s for contact info
…ly resolving the cypress error in CI
…es work, I just ran a script incorrectly--and update the filter in getJudgesChambersInteractor
@@ -0,0 +1,237 @@ | |||
import { JudgeChambersInfo } from '@shared/proxies/users/getJudgesChambersProxy'; | |||
|
|||
const JUDGES_CHAMBERS: Record<string, JudgeChambersInfo> = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To be pared down or removed after we run scripts/run-once-scripts/add-phone-numbers-to-judge-records.ts
@@ -30,7 +30,7 @@ describe('Get users in section', () => { | |||
{ | |||
...mockJudgeUser, | |||
isSeniorJudge: false, | |||
judgeFullName: 'Test Judge 1', | |||
judgeFullName: 'Test Judge 2', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Judge 1 is above
applicationContext, | ||
get, | ||
}: ActionProps) => { | ||
const judgesChambersCached = get(state.judgesChambers); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updates to chambers are relatively infrequent, so I think it is best to cache.
…ser and add-judge
…te name updates until future story
…te Way's number in mockJudgesChambers
Purpose
We hard code chambers data in getJudgesChambers.ts and in add-user.ts. This requires us to deploy code in order to add/remove/update a judge. The goal of this PR is to decouple modifications to judges and code deployments in test/prod and to provide clear steps for onboarding/updating a judge. (#5217 demonstrated to us that this process was not clear/well-documented.)
Note that this PR attempts to do the minimal-ish work possible to accomplish these goals.
Current Problems
1. Hard-coded data
Functionally, we use hard-coded chambers data in a few spots:
getJudgesChambers.ts
add-user.ts
This PR removes the above hard-coded logic and instead creates a new endpoint (and associated lambda, proxy, and actions) to get/set judge chambers information from our database. It also makes slight updates for loading judges in non-test/prod environments. (See Environment-Specific Considerations below.)
2. Unclear processes for adding/updating a judge
Our processes for onboarding/updating a judge are not well-documented and are ad-hoc. (See this PR.) This PR adds a few (admittedly miserable) scripts as a slight improvement.
Broad Overview of the Implementation
Most of the hard-coded data we want to decouple from is already available in the database. The one exception is judge chambers' phone numbers; they were only ever in
getJudgesChambers.ts
. Maybe the most conceptually appropriate way to get them into non-hard-coded persistence would be to add the phone number to the chambers record (and maybe even create a chambers entity) since, technically, the phone number is for each judge's chambers section and not for the judge themselves.However, our chambers records are currently very sparse; in fact, the only attributes they have are the pk (e.g.,
section|soAndSoChambers
) and the sk (which is just the userId of the judge). Given the added complexity of the "chambers-first" approach (which would require stitching together some records)--and given the fact that the only non-pk attribute for chambers' records is just a reference to the relevant judge anyway--I decided on a "judges-first" approach in which we add the phone number to the judge record. This is easier because 1) we can get all the information we need from one set of records rather than stitching data together and 2) a judge is already aUser
entity with acontact
attribute.Environment-Specific Considerations
We have to update judge phone numbers in three separate ways depending on the environment:
getJudgesChambers.ts
) to the judge users inefcms-local.json
. (Otherwise, tests relying on this, if any, will fail.)bulkImportJudgeUsers.helpers.ts
similarly.add-phone-numbers-to-judge-records.ts
, to update current judges. I've also providedadd-judge.ts
andupdate-judge.ts
so that new judges can be onboarded/updated more efficiently.Manual Steps
We need to run
scripts/run-once-scripts/add-phone-numbers-to-judge-records.ts
before deploying.Fast-follow tasks:
After
scripts/run-once-scripts/add-phone-numbers-to-judge-records.ts
is run, we should pare down and maybe remove entirelyJUDGES_CHAMBERS
. While still used in some tests, I believe we may only strictly need it for the one-time script add-phone-numbers-to-judge-records.ts.We can also remove
scripts/run-once-scripts/add-phone-numbers-to-judge-records.ts
.Issues:
Tests:
scripts/run-once-scripts/add-phone-numbers-to-judge-records.ts
in experimentalscripts/user/add-judge.ts
in experimentalscripts/user/update-judge.ts
in experimentalscripts/user/add-user.ts
get the chambers sections dynamically in experimentalscripts/run-once-scripts/add-phone-numbers-to-judge-records.ts
in testscripts/user/add-judge.ts
in testscripts/user/update-judge.ts
in testscripts/user/add-user.ts
get the chambers sections dynamically in testadd-phone-numbers...
and 2) something like this, at least, for test data like in messageModalHelper.test.ts.Fast-follow tasks:
JUDGES_CHAMBERS
. While still used in some tests, I believe we may only strictly need it for the one-time scriptadd-phone-numbers-to-judge-records.ts
.