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

10504 dxox: Case Deadlines, Correspondences, and Worksheets #5520

Draft
wants to merge 123 commits into
base: staging
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 34 commits
Commits
Show all changes
123 commits
Select commit Hold shift + click to select a range
e8420a8
10391 - starting work to refactor work items
codyseibert Sep 24, 2024
16f12f6
10391 - refactoring the qc inbox to use postgres instead of elasticse…
codyseibert Sep 24, 2024
5c74ea9
10391 - refactoring a few more methods
codyseibert Sep 24, 2024
f59ff36
10391: sort prop fields in seed data
jtdevos Sep 24, 2024
c2eb549
Merge branch '10391-work-item-refactor' of https://github.com/flexion…
jtdevos Sep 24, 2024
e000047
10491 - refactoring more work items
codyseibert Sep 26, 2024
51b188d
Merge branch '10391-dynamo-migrations-kysely-aurora-rds-tokens' of gi…
pixiwyn Sep 27, 2024
50887b3
10491: Refactor out duplicate case details
pixiwyn Sep 27, 2024
15f86d2
10491: join with case
pixiwyn Sep 27, 2024
3879a0d
10491: covert remaining dynamodb functions
pixiwyn Sep 27, 2024
1159aa5
10491: fix lint errors
pixiwyn Sep 30, 2024
34676fc
Merge branch '10391-dynamo-migrations-kysely-aurora-rds-tokens' of gi…
pixiwyn Sep 30, 2024
0f98fef
Merge branch '10391-dynamo-migrations-kysely-aurora-rds-tokens' of gi…
pixiwyn Oct 2, 2024
b4f8c99
10491 - trying to fix work items
codyseibert Oct 2, 2024
13b715a
10491: add mocks + use in api test
pixiwyn Oct 2, 2024
49fea39
10491: fix workitems mock import name
pixiwyn Oct 2, 2024
23ae202
10491: fix mocks path
pixiwyn Oct 2, 2024
4b3c9cf
10491 - fetching work items when doing queryFull
codyseibert Oct 3, 2024
d630e0f
Merge branch '10391-dynamo-migrations-kysely-aurora-rds-tokens' of gi…
pixiwyn Oct 4, 2024
604212f
10491: refactor to use prefix
pixiwyn Oct 4, 2024
1a060ac
10491: fix shared tests
pixiwyn Oct 4, 2024
b88f8c9
10491: fix linting errors
pixiwyn Oct 4, 2024
4e1e5a7
10491: update broken mock
pixiwyn Oct 4, 2024
e6368ca
10491: fix mocks
pixiwyn Oct 4, 2024
69a625e
10491: remove unnecessary tests + add mock values
pixiwyn Oct 8, 2024
0df7f78
10491: fix shared tests
pixiwyn Oct 8, 2024
a1a39c9
10491: update association if workItems and add mock
pixiwyn Oct 8, 2024
abc2f20
10491: add additional mocks
pixiwyn Oct 8, 2024
508e7ad
10491: add default returnValue
pixiwyn Oct 8, 2024
ec2e952
10491: fix shared tests
pixiwyn Oct 8, 2024
0ba8e15
10491: fix api tests
pixiwyn Oct 8, 2024
058cd40
Merge branch 'staging' of github.com:ustaxcourt/ef-cms into 10491-wor…
pixiwyn Oct 8, 2024
ac16041
10491: fix more tests
pixiwyn Oct 8, 2024
5ed20d2
fixing some integration tests
codyseibert Oct 8, 2024
31eab83
Merge branch '10491-work-item-refactor' of github.com:flexion/ef-cms …
codyseibert Oct 8, 2024
aa5651f
10491: fix sentWorkItemsExpireAfterNDays.test.ts
pixiwyn Oct 8, 2024
c16b3b4
Merge branch '10491-work-item-refactor' of github.com:flexion/ef-cms …
pixiwyn Oct 8, 2024
2685218
10491 - fixing integration test
codyseibert Oct 9, 2024
b5919db
10491: fix api tests
pixiwyn Oct 9, 2024
3575038
10491 - fixing more integration tests
codyseibert Oct 9, 2024
1ec0f19
Merge branch '10491-work-item-refactor' of github.com:flexion/ef-cms …
codyseibert Oct 9, 2024
4495d6d
10491: fix api tests
pixiwyn Oct 9, 2024
6f92426
Merge branch '10491-work-item-refactor' of github.com:flexion/ef-cms …
pixiwyn Oct 9, 2024
663d6ae
10491: fix api tests
pixiwyn Oct 9, 2024
0208f12
10491 - fixing more integration tests
codyseibert Oct 9, 2024
0e8fb91
10491 - fixing more integration tests
codyseibert Oct 9, 2024
9bf112d
10491: fix remaining tests (hopefully?)
pixiwyn Oct 10, 2024
bc09c44
10491: fix last test
pixiwyn Oct 11, 2024
4d4787e
10504: start case correspondence + deadline
pixiwyn Oct 11, 2024
b1f6ade
10504: add additional case deadline queries
pixiwyn Oct 11, 2024
a0a6557
10504: remove old case deadline queries
pixiwyn Oct 11, 2024
8af8edd
10504: add seed data
pixiwyn Oct 11, 2024
3d157ab
10504: fix error with docket number
pixiwyn Oct 11, 2024
1da7c2d
10504: add correspondence seed
pixiwyn Oct 11, 2024
d13d26c
10491: add case correspondence
pixiwyn Oct 11, 2024
98dcdf6
10504: add case worksheets
pixiwyn Oct 11, 2024
2747950
10492: resolve conflicts
pixiwyn Nov 6, 2024
f0252e3
10491: update spell check
pixiwyn Nov 6, 2024
a0e67e2
Merge branch 'staging' of github.com:ustaxcourt/ef-cms into 10504-dxox
pixiwyn Nov 6, 2024
41c118c
10491-work-item-refactor: fix failing tests and type errors
Mwindo Nov 6, 2024
9471803
10504-dxox: remove case-dealine| and fix correspondence mock file and…
Mwindo Nov 6, 2024
68c798b
10504-dxox: add mocks.jest.ts files, and fix updateCaseAndAssociation…
Mwindo Nov 6, 2024
d22ec53
10504-dxox: fix updatePetitionerInformationInteractor.test.ts
Mwindo Nov 6, 2024
ddeea43
10504-dxox: fix CaseDeadline.test.ts, getCaseDeadlnesInteractor.test.…
Mwindo Nov 6, 2024
b13ad2d
10504-dxox: fixing a whole lotta api tests
Mwindo Nov 7, 2024
8cc25ac
10504-dxox: fix shared test
Mwindo Nov 7, 2024
fecdc98
10504-dxox: fix more API tests
Mwindo Nov 7, 2024
016287e
10504-dxox: fix a few more tests, undo a change to MOCK_CASE (which w…
Mwindo Nov 7, 2024
81af9d7
10504-dxox: fix more tests, and some types
Mwindo Nov 7, 2024
db2846a
10504-dxox: remove dynamo persistence from client test application co…
Mwindo Nov 7, 2024
a09c769
10504-dxox: fix failing scripts test
Mwindo Nov 7, 2024
739a7d7
10504-dxox: fix failing integration test
Mwindo Nov 7, 2024
cba4b8c
10504-dxox: null check in caseWorksheet mapper
Mwindo Nov 8, 2024
3fbe127
10504-dxox: fix integration tests failing for timezone reasons
Mwindo Nov 8, 2024
3df68d9
10504-dxox: fix more timezone format mismatches in tests
Mwindo Nov 8, 2024
54c0cab
10504-dxox: change createCaseDeadline to upserCaseDeadline, and relat…
Mwindo Nov 8, 2024
891ae7a
10504-dxox: fix script test and api tests
Mwindo Nov 8, 2024
967414b
10504-dxox: remove numberOfPages, which looks like it was a spurious …
Mwindo Nov 11, 2024
86cca87
10504-dxox: remove numberOfPages from migration
Mwindo Nov 11, 2024
bcab627
10504-dxox: WIP using upsertCaseCorrespondences instead of upsertCase…
Mwindo Nov 12, 2024
00458dc
10504-dxox: WIP, make stream processors for deadlines, correspondence…
Mwindo Nov 12, 2024
f687585
10504-dxox: fix incorrect keys in processStreamUtilities; replace ups…
Mwindo Nov 13, 2024
60114d3
10504-dxox: update some tests after the previous refactor
Mwindo Nov 13, 2024
037f5b8
10504-dxox: add deletition scripts, add validation for judge id to Ca…
Mwindo Nov 13, 2024
830ab53
10504-dxox: add tests to new stream processors, and update postgres d…
Mwindo Nov 13, 2024
fcbf4ba
10504-dxox: fix validateCaseWorksheetAction.test, and avoid passing …
Mwindo Nov 13, 2024
fee1eaf
10504-dxox: add 'so far' to deletion scripts
Mwindo Nov 13, 2024
7ecc01b
10504-dxox: update postgres run-once scripts to have correct HOW TO R…
Mwindo Nov 14, 2024
4d63bd8
10504-dxox: merge in staging, and re-add docketNumber in Case assignC…
Mwindo Nov 14, 2024
88c1362
10504-dxox: remove docketNumber in assignCorrespondences since it see…
Mwindo Nov 15, 2024
c387e5a
10504-dxox: remove unused import
Mwindo Nov 20, 2024
d206648
10504-dxox: readd docketNumber in assignCorrespondences, which is nec…
Mwindo Nov 20, 2024
49a723a
10491-dxox: add delete script for work items; todo, delete script for…
Mwindo Nov 20, 2024
8c7b54d
10491-dxox: add delete scripts for outboxes
Mwindo Nov 20, 2024
38d4183
10491-work-items: update delete scripts
Mwindo Dec 3, 2024
b86bed9
10504-dxox: update delete script
Mwindo Dec 3, 2024
aa2df5b
Merge branch 'staging' of github.com:ustaxcourt/ef-cms into 10491-wor…
pixiwyn Dec 3, 2024
14920cd
Merge branch 'staging' into 10504-dxox
pixiwyn Dec 4, 2024
f62ed84
10504-dxox: update overlooked delete scripts and add CIRCLE_BRANCH var
Mwindo Dec 4, 2024
f7cabd7
10504-dxox: experiment to prevent creating lots of db connections
Mwindo Dec 4, 2024
e0693cd
Merge remote-tracking branch 'ustc/staging' into 10504-dxox
Mwindo Dec 4, 2024
68f04f8
10504: Reuse existing connection if possible
pixiwyn Dec 5, 2024
8200d45
10504-dxox: fix type error
Mwindo Dec 5, 2024
2f511b0
10504-dxox: fix processCaseCorrespondenceEntries and processCaseWorks…
Mwindo Dec 6, 2024
58aa324
10504-dxox: fix typo gs1pk to gsi1pk, fix failing test, and improve t…
Mwindo Dec 6, 2024
5aeba6f
10504-dxox: fix entityName typo
Mwindo Dec 6, 2024
2833a46
10491-dxox: change saveWorkItem to upsertWorkItems for consistency wi…
Mwindo Dec 10, 2024
768602a
10491-dxox: upsert work items into postgres and add test; also, use g…
Mwindo Dec 10, 2024
e74c2fe
10491-dxox: fix overlooked renames
Mwindo Dec 10, 2024
2ecea56
10491-dxox: upsert last in processWorkItemEntries to prevent latency …
Mwindo Dec 10, 2024
f58a675
10491-dxox: add indices to work-items and restructure queries slightl…
Mwindo Dec 11, 2024
3125857
10504-dxox: add indices
Mwindo Dec 11, 2024
dc7e93a
10504-dxox: merge 10491
Mwindo Dec 12, 2024
9b3a8e5
10504: update lock file
Mwindo Dec 12, 2024
be2371e
10504-dxox: fix up delete scripts slightly
Mwindo Dec 16, 2024
a6a8c77
10504-dxox: fix sks in delete scripts
Mwindo Dec 16, 2024
7ea0166
10491: return workItem when submitting paper filing
pixiwyn Dec 17, 2024
44a059e
10491: add test for new optional work item and work item id
pixiwyn Dec 17, 2024
43a4436
Merge branch 'staging' of github.com:ustaxcourt/ef-cms into 10491-wor…
pixiwyn Dec 17, 2024
81b76f1
10491: update package lock file
pixiwyn Dec 17, 2024
9ab7121
10491: fix broken tests
pixiwyn Dec 17, 2024
4d9d161
Merge branch '10491-work-item-refactor' into 10504-dxox after changes…
Mwindo Dec 17, 2024
c14d6fc
10504-dxox: fix finalBriefDueDate issue
Mwindo Dec 18, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions __TODO_10504.txt
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
3 changes: 0 additions & 3 deletions docs/dynamodb-access-patterns.csv
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
Access Scenario,PK,SK,GS1PK,GSI2PK
the case deadline object,case-deadline|${DEADLINE_ID},case-deadline|${DEADLINE_ID},
associate a deadline with a case (mapping record),case|${CASE_ID},case-deadline|${DEADLINE_ID},
a case,case|${CASE_ID},case|${CASE_ID},leadCase|${LEAD_CASE_ID}
associate an irs practitioner onto a case,case|${CASE_ID},irsPractitioner|${USER_ID},leadCase|${LEAD_CASE_ID}
associate a private practitioner onto a case,case|${CASE_ID},privatePractitioner|${USER_ID},leadCase|${LEAD_CASE_ID}
associate docket entry on a case,case|${CASE_ID},docket-entry|${DOCKET_ENTRY_ID},
add correspondence to a case,case|${CASE_ID},correspondence|${CORRESPONDENCE_ID},
add a hearing to a case,case|${CASE_ID},hearing|${TRIAL_SESSION_ID},
a work item on a case,case|${CASE_ID},work-item|${WORK_ITEM_ID},work-item|${WORK_ITEM_ID},assigneeId|${ASSIGNEE_ID}
docket number generator counter,docketNumberCounter-${YEAR},docketNumberCounter-${YEAR},
Expand Down
3 changes: 3 additions & 0 deletions scripts/dynamo/fix-race-condition-served-in-drafts.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
/*
* @jest-environment node
*/
import '@web-api/persistence/postgres/caseCorrespondences/mocks.jest';
import '@web-api/persistence/postgres/cases/mocks.jest';

import { DynamoDBClient, GetItemCommand } from '@aws-sdk/client-dynamodb';
import { MOCK_DOCUMENTS } from '@shared/test/mockDocketEntry';
import { applicationContext } from '@shared/business/test/createTestApplicationContext';
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
import {
Copy link
Contributor

@Mwindo Mwindo Nov 13, 2024

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.

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;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
/**
* 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: ${totalItemsDeleted}`);
offset += caseCorrespondencePageSize;
caseCorrespondencesToDelete = await getCaseCorrespondencesToDelete(offset);
}
console.log('Done deleting case correspondences from Dynamo');
}

main().catch(console.error);
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: ${totalItemsDeleted}`);
offset += caseDeadlinePageSize;
caseDeadlinesToDelete = await getCaseDeadlinesToDelete(offset);
}
console.log('Done deleting case deadlines from Dynamo');
}

main().catch(console.error);
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: ${totalItemsDeleted}`);
offset += caseWorksheetPageSize;
caseWorksheetsToDelete = await getCaseWorksheetsToDelete(offset);
}
console.log('Done deleting case worksheets from Dynamo');
}

main().catch(console.error);
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
ScanCommand,
} from '@aws-sdk/lib-dynamodb';
import { DynamoDBClient, ScanCommandInput } from '@aws-sdk/client-dynamodb';
import { requireEnvVars } from '../../shared/admin-tools/util';
import { requireEnvVars } from '../../../shared/admin-tools/util';

requireEnvVars(['TABLE_NAME']);

Expand Down
Loading
Loading