Skip to content

Commit

Permalink
Merge pull request #5727 from flexion/10504-dxox-add-missing-commit-t…
Browse files Browse the repository at this point in the history
…o-staging

10504: Adding commits from test that did not get into staging
  • Loading branch information
jimlerza authored Jan 26, 2025
2 parents 8417c6a + 5f478d0 commit 363bfc1
Show file tree
Hide file tree
Showing 7 changed files with 113 additions and 55 deletions.
4 changes: 2 additions & 2 deletions shared/src/business/entities/Correspondence.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export class Correspondence extends JoiValidationEntity {
public filedBy: string;
public filingDate: string;
public userId: string;
public docketNumber: string;
public docketNumber?: string; // Not optional but required as such to enable migration with dynamoDB

constructor(rawProps) {
super('Correspondence');
Expand All @@ -30,7 +30,7 @@ export class Correspondence extends JoiValidationEntity {
.optional()
.description('A correspondence document that was archived.'),
correspondenceId: JoiValidationConstants.UUID.required(),
docketNumber: JoiValidationConstants.STRING.max(10).required(),
docketNumber: JoiValidationConstants.STRING.max(10).optional(),
documentTitle: JoiValidationConstants.STRING.max(500).required(),
filedBy: JoiValidationConstants.STRING.max(500).allow('').optional(),
filingDate: JoiValidationConstants.ISO_DATE.max('now')
Expand Down
4 changes: 2 additions & 2 deletions shared/src/business/entities/caseWorksheet/CaseWorksheet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export class CaseWorksheet extends JoiValidationEntity {
public finalBriefDueDate?: string;
public primaryIssue?: string;
public statusOfMatter?: string;
public judgeUserId: string;
public judgeUserId?: string;

constructor(rawProps) {
super('CaseWorksheet');
Expand Down Expand Up @@ -37,7 +37,7 @@ export class CaseWorksheet extends JoiValidationEntity {
.messages({
'*': 'Enter a valid due date',
}),
judgeUserId: JoiValidationConstants.UUID.required(),
judgeUserId: JoiValidationConstants.UUID.optional(),
primaryIssue: JoiValidationConstants.STRING.allow('').optional(),
statusOfMatter: JoiValidationConstants.STRING.valid(
...CaseWorksheet.STATUS_OF_MATTER_OPTIONS,
Expand Down
48 changes: 32 additions & 16 deletions web-api/src/persistence/dynamo/cases/getCaseByDocketNumber.test.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,21 @@
import '@web-api/persistence/postgres/cases/mocks.jest';
import '@web-api/persistence/postgres/caseCorrespondences/mocks.jest';
import '@web-api/persistence/postgres/cases/mocks.jest';
import '@web-api/persistence/postgres/workitems/mocks.jest';
import {
CASE_STATUS_TYPES,
ROLES,
} from '../../../../../shared/src/business/entities/EntityConstants';
import { applicationContext } from '../../../../../shared/src/business/test/createTestApplicationContext';
} from '@shared/business/entities/EntityConstants';
import { applicationContext } from '@shared/business/test/createTestApplicationContext';
import { calculateDate } from '@shared/business/utilities/DateHandler';
import { caseCorrespondenceEntity } from '@web-api/persistence/postgres/caseCorrespondences/mapper';
import { getCaseByDocketNumber } from './getCaseByDocketNumber';
import { getCaseCorrespondenceByDocketNumber as getCaseCorrespondenceByDocketNumberMock } from '@web-api/persistence/postgres/caseCorrespondences/getCaseCorrespondenceByDocketNumber';
import { getCaseByDocketNumberPostgres as getCaseByDocketNumberPostgresMock } from '@web-api/persistence/postgres/cases/getCaseByDocketNumber';

const getCaseCorrespondenceByDocketNumber =
getCaseCorrespondenceByDocketNumberMock as jest.Mock;
const getCaseByDocketNumberPostgres =
getCaseByDocketNumberPostgresMock as jest.Mock;

describe('getCaseByDocketNumber', () => {
beforeEach(() => {
(getCaseCorrespondenceByDocketNumber as jest.Mock).mockResolvedValue([]);
getCaseByDocketNumberPostgres.mockResolvedValue([]);
});

it('should return data as received from persistence', async () => {
Expand Down Expand Up @@ -51,19 +50,21 @@ describe('getCaseByDocketNumber', () => {
});

it('should return case and its associated data', async () => {
getCaseCorrespondenceByDocketNumber.mockResolvedValue([
caseCorrespondenceEntity({
getCaseByDocketNumberPostgres.mockResolvedValue([
{
archived: false,
correspondenceId: 'abc-124',
docketNumber: '123-20',
filingDate: calculateDate({ dateString: '2024-11-06T21:05:08.191Z' }),
}),
caseCorrespondenceEntity({
},
{
archived: true,
correspondenceId: 'abc-123',
docketNumber: '123-20',
filingDate: calculateDate({
dateString: '2024-11-06T21:05:08.191Z',
}),
}),
},
]);

applicationContext.getDocumentClient().query.mockResolvedValue({
Expand Down Expand Up @@ -118,7 +119,15 @@ describe('getCaseByDocketNumber', () => {
});

expect(result).toEqual({
archivedCorrespondences: [],
archivedCorrespondences: [
{
archived: true,
correspondenceId: 'abc-123',
docketNumber: '123-20',
entityName: 'Correspondence',
filingDate: '2024-11-06T21:05:08.191Z',
},
],
archivedDocketEntries: [
{
archived: true,
Expand All @@ -127,12 +136,19 @@ describe('getCaseByDocketNumber', () => {
],
associatedJudge: 'Judge Fieri',
consolidatedCases: [],
correspondence: [],
correspondence: [
{
archived: false,
correspondenceId: 'abc-124',
docketNumber: '123-20',
entityName: 'Correspondence',
filingDate: '2024-11-06T21:05:08.191Z',
},
],
docketEntries: [
{
archived: false,
docketEntryId: 'abc-124',
workItem: undefined,
},
],
docketNumber: '123-20',
Expand Down
34 changes: 16 additions & 18 deletions web-api/src/persistence/dynamo/cases/getCaseByDocketNumber.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ import { caseCorrespondenceEntity } from '@web-api/persistence/postgres/caseCorr
import { getCaseByDocketNumberPostgres } from '@web-api/persistence/postgres/cases/getCaseByDocketNumber';
import { purgeDynamoKeys } from '@web-api/persistence/dynamo/helpers/purgeDynamoKeys';
import { queryFull } from '../../dynamodbClientService';
import { caseContactAddressSealedFormatter } from '@shared/business/utilities/caseFilter';
import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser';
import { workItemEntity } from '@web-api/persistence/postgres/workitems/mapper';
import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser';
import { caseContactAddressSealedFormatter } from '@shared/business/utilities/caseFilter';

// These case items are no longer in dynamoDB
const SK_FILTER_OUT = ['work-item'];
const SK_FILTER_OUT = ['work-item', 'correspondence'];

export const getCaseByDocketNumber = async ({
applicationContext,
Expand All @@ -35,22 +35,20 @@ export const getCaseByDocketNumber = async ({
includeCorrespondenceAndWorkItems?: boolean;
user?: UnknownAuthUser;
}): Promise<RawCase> => {
const [caseItems] = await Promise.all([
queryFull({
ExpressionAttributeNames: {
'#pk': 'pk',
},
ExpressionAttributeValues: {
':pk': `case|${docketNumber}`,
},
KeyConditionExpression: '#pk = :pk',
applicationContext,
}).then(items =>
items.filter(
item => !SK_FILTER_OUT.some(prefix => item.sk.startsWith(prefix)),
),
const caseItems = await queryFull({
ExpressionAttributeNames: {
'#pk': 'pk',
},
ExpressionAttributeValues: {
':pk': `case|${docketNumber}`,
},
KeyConditionExpression: '#pk = :pk',
applicationContext,
}).then(items =>
items.filter(
item => !SK_FILTER_OUT.some(prefix => item.sk.startsWith(prefix)),
),
]);
);

/*
We have roughly three options to get all data associated with a case:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export const upsertCaseCorrespondences = async (
return {
archived: correspondence.archived,
correspondenceId: correspondence.correspondenceId,
docketNumber: correspondence.docketNumber,
docketNumber: correspondence.docketNumber!,
documentTitle: correspondence.documentTitle,
filedBy: correspondence.filedBy,
filingDate: calculateDate({ dateString: correspondence.filingDate }),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
import { Kysely } from 'kysely';

export async function up(db: Kysely<any>): Promise<void> {
await db.schema
.createIndex('idx_caseCorrespondence_docketNumber')
.on('dwCaseCorrespondence')
.column('docketNumber')
.execute();

await db.schema
.createIndex('idx_caseDeadline_docketNumber')
.on('dwCaseDeadline')
.column('docketNumber')
.execute();

await db.schema
.createIndex('idx_caseDeadline_deadlineDate')
.on('dwCaseDeadline')
.column('deadlineDate')
.execute();

await db.schema
.createIndex('idx_caseDeadline_sortableDocketNumber')
.on('dwCaseDeadline')
.column('sortableDocketNumber')
.execute();

await db.schema
.createIndex('idx_caseDeadline_associatedJudge')
.on('dwCaseDeadline')
.column('associatedJudge')
.execute();
}

export async function down(db: Kysely<any>): Promise<void> {
await db.schema
.dropIndex('idx_caseDeadline_associatedJudge')
.on('dwCaseDeadline')
.execute();

await db.schema
.dropIndex('idx_caseDeadline_sortableDocketNumber')
.on('dwCaseDeadline')
.execute();

await db.schema
.dropIndex('idx_caseDeadline_deadlineDate')
.on('dwCaseDeadline')
.execute();

await db.schema
.dropIndex('idx_caseDeadline_docketNumber')
.on('dwCaseDeadline')
.execute();

await db.schema
.dropIndex('idx_caseCorrespondence_docketNumber')
.on('dwCaseCorrespondence')
.execute();
}

This file was deleted.

0 comments on commit 363bfc1

Please sign in to comment.