-
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
10504 dxox #5520
Draft
pixiwyn
wants to merge
36
commits into
ustaxcourt:staging
Choose a base branch
from
flexion:10504-dxox
base: staging
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
10504 dxox #5520
Changes from all commits
Commits
Show all changes
36 commits
Select commit
Hold shift + click to select a range
4d4787e
10504: start case correspondence + deadline
pixiwyn b1f6ade
10504: add additional case deadline queries
pixiwyn a0a6557
10504: remove old case deadline queries
pixiwyn 8af8edd
10504: add seed data
pixiwyn 3d157ab
10504: fix error with docket number
pixiwyn 1da7c2d
10504: add correspondence seed
pixiwyn d13d26c
10491: add case correspondence
pixiwyn 98dcdf6
10504: add case worksheets
pixiwyn a0e67e2
Merge branch 'staging' of github.com:ustaxcourt/ef-cms into 10504-dxox
pixiwyn 9471803
10504-dxox: remove case-dealine| and fix correspondence mock file and…
Mwindo 68c798b
10504-dxox: add mocks.jest.ts files, and fix updateCaseAndAssociation…
Mwindo d22ec53
10504-dxox: fix updatePetitionerInformationInteractor.test.ts
Mwindo ddeea43
10504-dxox: fix CaseDeadline.test.ts, getCaseDeadlnesInteractor.test.…
Mwindo b13ad2d
10504-dxox: fixing a whole lotta api tests
Mwindo 8cc25ac
10504-dxox: fix shared test
Mwindo fecdc98
10504-dxox: fix more API tests
Mwindo 016287e
10504-dxox: fix a few more tests, undo a change to MOCK_CASE (which w…
Mwindo 81af9d7
10504-dxox: fix more tests, and some types
Mwindo db2846a
10504-dxox: remove dynamo persistence from client test application co…
Mwindo a09c769
10504-dxox: fix failing scripts test
Mwindo 739a7d7
10504-dxox: fix failing integration test
Mwindo cba4b8c
10504-dxox: null check in caseWorksheet mapper
Mwindo 3fbe127
10504-dxox: fix integration tests failing for timezone reasons
Mwindo 3df68d9
10504-dxox: fix more timezone format mismatches in tests
Mwindo 54c0cab
10504-dxox: change createCaseDeadline to upserCaseDeadline, and relat…
Mwindo 891ae7a
10504-dxox: fix script test and api tests
Mwindo 967414b
10504-dxox: remove numberOfPages, which looks like it was a spurious …
Mwindo 86cca87
10504-dxox: remove numberOfPages from migration
Mwindo bcab627
10504-dxox: WIP using upsertCaseCorrespondences instead of upsertCase…
Mwindo 00458dc
10504-dxox: WIP, make stream processors for deadlines, correspondence…
Mwindo f687585
10504-dxox: fix incorrect keys in processStreamUtilities; replace ups…
Mwindo 60114d3
10504-dxox: update some tests after the previous refactor
Mwindo 037f5b8
10504-dxox: add deletition scripts, add validation for judge id to Ca…
Mwindo 830ab53
10504-dxox: add tests to new stream processors, and update postgres d…
Mwindo fcbf4ba
10504-dxox: fix validateCaseWorksheetAction.test, and avoid passing …
Mwindo fee1eaf
10504-dxox: add 'so far' to deletion scripts
Mwindo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
check Correspondence works now with docketNumber (added to the entity) and update validation? | ||
|
||
-- | ||
|
||
Is docketNumber in Case assignCorrespondences necessary? Were there some old cases, maybe, onto which we directly stored correspondences? | ||
|
||
|
||
-- | ||
|
||
check CaseWorksheet works now with judgeUserId (added to the entity) and update validation? | ||
|
||
-- | ||
|
||
entityName: "CaseWorksheet" in updateCaseWorksheetAction is silly | ||
|
||
-- | ||
|
||
add missing tests |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 63 additions & 0 deletions
63
scripts/run-once-scripts/postgres-migration/batch-delete-dynamo-items.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import { | ||
BatchWriteCommand, | ||
DynamoDBDocumentClient, | ||
} from '@aws-sdk/lib-dynamodb'; | ||
|
||
export async function batchDeleteDynamoItems( | ||
itemsToDelete: { DeleteRequest: { Key: { pk: string; sk: string } } }[], | ||
client: DynamoDBDocumentClient, | ||
tableNameInput: string, | ||
): Promise<number> { | ||
const BATCH_SIZE = 25; | ||
const RETRY_DELAY_MS = 5000; // Set the delay between retries (in milliseconds) | ||
let totalItemsDeleted = 0; | ||
|
||
for (let i = 0; i < itemsToDelete.length; i += BATCH_SIZE) { | ||
const batch = itemsToDelete.slice(i, i + BATCH_SIZE); | ||
|
||
const batchWriteParams = { | ||
RequestItems: { | ||
[tableNameInput]: batch, | ||
}, | ||
}; | ||
|
||
try { | ||
let unprocessedItems: any[] = batch; | ||
let retryCount = 0; | ||
const MAX_RETRIES = 5; | ||
|
||
// Retry logic for unprocessed items | ||
while (unprocessedItems.length > 0 && retryCount < MAX_RETRIES) { | ||
const response = await client.send( | ||
new BatchWriteCommand(batchWriteParams), | ||
); | ||
|
||
totalItemsDeleted += | ||
unprocessedItems.length - | ||
(response.UnprocessedItems?.[tableNameInput]?.length || 0); | ||
|
||
unprocessedItems = response.UnprocessedItems?.[tableNameInput] ?? []; | ||
|
||
if (unprocessedItems.length > 0) { | ||
console.log( | ||
`Retrying unprocessed items: ${unprocessedItems.length}, attempt ${retryCount + 1}`, | ||
); | ||
batchWriteParams.RequestItems[tableNameInput] = unprocessedItems; | ||
retryCount++; | ||
|
||
// Add delay before the next retry | ||
await new Promise(resolve => setTimeout(resolve, RETRY_DELAY_MS)); | ||
} | ||
} | ||
|
||
if (unprocessedItems.length > 0) { | ||
console.error( | ||
`Failed to delete ${unprocessedItems.length} items after ${MAX_RETRIES} retries.`, | ||
); | ||
} | ||
} catch (error) { | ||
console.error('Error in batch delete:', error); | ||
} | ||
} | ||
return totalItemsDeleted; | ||
} |
65 changes: 65 additions & 0 deletions
65
scripts/run-once-scripts/postgres-migration/delete-case-correspondences.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
/** | ||
* HOW TO RUN | ||
* | ||
* TABLE_NAME=testing npx ts-node --transpileOnly scripts/postgres/delete-case-correspondences.ts | ||
*/ | ||
|
||
import { DynamoDBDocumentClient } from '@aws-sdk/lib-dynamodb'; | ||
import { DynamoDBClient, ScanCommandInput } from '@aws-sdk/client-dynamodb'; | ||
import { requireEnvVars } from '../../../shared/admin-tools/util'; | ||
import { getDbReader } from '../../../web-api/src/database'; | ||
import { isEmpty } from 'lodash'; | ||
import { batchDeleteDynamoItems } from './batch-delete-dynamo-items'; | ||
|
||
const caseCorrespondencePageSize = 10000; | ||
const dynamoDbClient = new DynamoDBClient({ region: 'us-east-1' }); | ||
const dynamoDbDocClient = DynamoDBDocumentClient.from(dynamoDbClient); | ||
|
||
requireEnvVars(['TABLE_NAME']); | ||
|
||
const tableNameInput = process.env.TABLE_NAME!; | ||
|
||
const getCaseCorrespondencesToDelete = async (offset: number) => { | ||
const caseCorrespondences = await getDbReader(reader => | ||
reader | ||
.selectFrom('dwCaseCorrespondence') | ||
.select(['docketNumber', 'correspondenceId']) | ||
.orderBy('correspondenceId') | ||
.limit(caseCorrespondencePageSize) | ||
.offset(offset) | ||
.execute(), | ||
); | ||
return caseCorrespondences; | ||
}; | ||
|
||
let totalItemsDeleted = 0; | ||
|
||
async function main() { | ||
let offset = 0; | ||
let caseCorrespondencesToDelete = | ||
await getCaseCorrespondencesToDelete(offset); | ||
|
||
while (!isEmpty(caseCorrespondencesToDelete)) { | ||
const dynamoItemsToDelete = caseCorrespondencesToDelete.map(cd => ({ | ||
DeleteRequest: { | ||
Key: { | ||
pk: `case|${cd.docketNumber}`, | ||
sk: `correspondence${cd.correspondenceId}`, | ||
}, | ||
}, | ||
})); | ||
totalItemsDeleted += await batchDeleteDynamoItems( | ||
dynamoItemsToDelete, | ||
dynamoDbDocClient, | ||
tableNameInput, | ||
); | ||
console.log( | ||
`Total case correspondences deleted so far: ${totalItemsDeleted}`, | ||
); | ||
offset += caseCorrespondencePageSize; | ||
caseCorrespondencesToDelete = await getCaseCorrespondencesToDelete(offset); | ||
} | ||
console.log('Done deleting case correspondences from Dynamo'); | ||
} | ||
|
||
main().catch(console.error); |
62 changes: 62 additions & 0 deletions
62
scripts/run-once-scripts/postgres-migration/delete-case-deadlines.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/** | ||
* HOW TO RUN | ||
* | ||
* TABLE_NAME=testing npx ts-node --transpileOnly scripts/postgres/delete-case-deadlines.ts | ||
*/ | ||
|
||
import { DynamoDBDocumentClient } from '@aws-sdk/lib-dynamodb'; | ||
import { DynamoDBClient } from '@aws-sdk/client-dynamodb'; | ||
import { requireEnvVars } from '../../../shared/admin-tools/util'; | ||
import { getDbReader } from '../../../web-api/src/database'; | ||
import { isEmpty } from 'lodash'; | ||
import { batchDeleteDynamoItems } from './batch-delete-dynamo-items'; | ||
|
||
const caseDeadlinePageSize = 10000; | ||
const dynamoDbClient = new DynamoDBClient({ region: 'us-east-1' }); | ||
const dynamoDbDocClient = DynamoDBDocumentClient.from(dynamoDbClient); | ||
|
||
requireEnvVars(['TABLE_NAME']); | ||
|
||
const tableNameInput = process.env.TABLE_NAME!; | ||
|
||
const getCaseDeadlinesToDelete = async (offset: number) => { | ||
const caseDeadlines = await getDbReader(reader => | ||
reader | ||
.selectFrom('dwCaseDeadline') | ||
.select(['docketNumber', 'caseDeadlineId']) | ||
.orderBy('caseDeadlineId') | ||
.limit(caseDeadlinePageSize) | ||
.offset(offset) | ||
.execute(), | ||
); | ||
return caseDeadlines; | ||
}; | ||
|
||
let totalItemsDeleted = 0; | ||
|
||
async function main() { | ||
let offset = 0; | ||
let caseDeadlinesToDelete = await getCaseDeadlinesToDelete(offset); | ||
|
||
while (!isEmpty(caseDeadlinesToDelete)) { | ||
const dynamoItemsToDelete = caseDeadlinesToDelete.map(cd => ({ | ||
DeleteRequest: { | ||
Key: { | ||
pk: `case|${cd.docketNumber}`, | ||
sk: `case-deadline|${cd.caseDeadlineId}`, | ||
}, | ||
}, | ||
})); | ||
totalItemsDeleted += await batchDeleteDynamoItems( | ||
dynamoItemsToDelete, | ||
dynamoDbDocClient, | ||
tableNameInput, | ||
); | ||
console.log(`Total case deadlines deleted so far: ${totalItemsDeleted}`); | ||
offset += caseDeadlinePageSize; | ||
caseDeadlinesToDelete = await getCaseDeadlinesToDelete(offset); | ||
} | ||
console.log('Done deleting case deadlines from Dynamo'); | ||
} | ||
|
||
main().catch(console.error); |
62 changes: 62 additions & 0 deletions
62
scripts/run-once-scripts/postgres-migration/delete-case-worksheets.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/** | ||
* HOW TO RUN | ||
* | ||
* TABLE_NAME=testing npx ts-node --transpileOnly scripts/postgres/delete-case-worksheets.ts | ||
*/ | ||
|
||
import { DynamoDBDocumentClient } from '@aws-sdk/lib-dynamodb'; | ||
import { DynamoDBClient } from '@aws-sdk/client-dynamodb'; | ||
import { requireEnvVars } from '../../../shared/admin-tools/util'; | ||
import { getDbReader } from '../../../web-api/src/database'; | ||
import { isEmpty } from 'lodash'; | ||
import { batchDeleteDynamoItems } from './batch-delete-dynamo-items'; | ||
|
||
const caseWorksheetPageSize = 10000; | ||
const dynamoDbClient = new DynamoDBClient({ region: 'us-east-1' }); | ||
const dynamoDbDocClient = DynamoDBDocumentClient.from(dynamoDbClient); | ||
|
||
requireEnvVars(['TABLE_NAME']); | ||
|
||
const tableNameInput = process.env.TABLE_NAME!; | ||
|
||
const getCaseWorksheetsToDelete = async (offset: number) => { | ||
const caseWorksheets = await getDbReader(reader => | ||
reader | ||
.selectFrom('dwCaseWorksheet') | ||
.select(['docketNumber']) | ||
.orderBy('docketNumber') | ||
.limit(caseWorksheetPageSize) | ||
.offset(offset) | ||
.execute(), | ||
); | ||
return caseWorksheets; | ||
}; | ||
|
||
let totalItemsDeleted = 0; | ||
|
||
async function main() { | ||
let offset = 0; | ||
let caseWorksheetsToDelete = await getCaseWorksheetsToDelete(offset); | ||
|
||
while (!isEmpty(caseWorksheetsToDelete)) { | ||
const dynamoItemsToDelete = caseWorksheetsToDelete.map(cd => ({ | ||
DeleteRequest: { | ||
Key: { | ||
pk: `case|${cd.docketNumber}`, | ||
sk: `case-worksheet|${cd.docketNumber}`, | ||
}, | ||
}, | ||
})); | ||
totalItemsDeleted += await batchDeleteDynamoItems( | ||
dynamoItemsToDelete, | ||
dynamoDbDocClient, | ||
tableNameInput, | ||
); | ||
console.log(`Total case worksheets deleted so far: ${totalItemsDeleted}`); | ||
offset += caseWorksheetPageSize; | ||
caseWorksheetsToDelete = await getCaseWorksheetsToDelete(offset); | ||
} | ||
console.log('Done deleting case worksheets from Dynamo'); | ||
} | ||
|
||
main().catch(console.error); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
This is just the script that was used for
delete-messages.ts
. I moved it here so it could be reusable.