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

chore(j-s): Logging more info for system status #16808

Merged
merged 6 commits into from
Nov 14, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -1669,23 +1669,6 @@ export class CaseService {
const schedulingNewArraignmentDateForIndictmentCase =
isIndictmentCase(theCase.type) && Boolean(updatedArraignmentDate)

if (update.accusedPostponedAppealDate) {
const relevantInfo = {
appealState: theCase.appealState,
accusedAppealDecision: theCase.accusedAppealDecision,
accusedPostponedAppealDate: theCase.accusedPostponedAppealDate,
prosecutorAppealDecision: theCase.prosecutorAppealDecision,
prosecutorPostponedAppealDate: theCase.prosecutorPostponedAppealDate,
update: update,
}

this.logger.info(
`Updating accusedPostponedAppealDate in case service for case ${
theCase.id
}. Relevant info: ${JSON.stringify(relevantInfo)}`,
)
}

return this.sequelize
.transaction(async (transaction) => {
if (receivingCase) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ export class InternalCaseController {
@ApiOkResponse({
type: Case,
isArray: true,
description: 'Gets all indictment cases',
description: 'Gets all indictment cases for digital mailbox',
})
@UseInterceptors(CasesInterceptor)
getIndictmentCases(
Expand All @@ -96,7 +96,7 @@ export class InternalCaseController {
@Post('case/indictment/:caseId')
@ApiOkResponse({
type: Case,
description: 'Gets indictment case by id',
description: 'Gets indictment case by id for digital mailbox',
})
@UseInterceptors(CaseInterceptor)
getIndictmentCase(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1223,6 +1223,12 @@ export class InternalCaseService {
attributes: ['id', 'courtCaseNumber', 'type', 'state'],
where: {
type: CaseType.INDICTMENT,
// Make sure we don't send cases that are in deleted or other inaccessible states
oddsson marked this conversation as resolved.
Show resolved Hide resolved
state: [
CaseState.RECEIVED,
CaseState.COMPLETED,
CaseState.WAITING_FOR_CANCELLATION,
],
// The national id could be without a hyphen or with a hyphen so we need to
// search for both
'$defendants.national_id$': normalizeAndFormatNationalId(nationalId),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -314,23 +314,6 @@ export class LimitedAccessCaseService {
update: LimitedAccessUpdateCase,
user: TUser,
): Promise<Case> {
if (update.accusedPostponedAppealDate) {
const relevantInfo = {
appealState: theCase.appealState,
accusedAppealDecision: theCase.accusedAppealDecision,
accusedPostponedAppealDate: theCase.accusedPostponedAppealDate,
prosecutorAppealDecision: theCase.prosecutorAppealDecision,
prosecutorPostponedAppealDate: theCase.prosecutorPostponedAppealDate,
update: update,
}

this.logger.info(
`Updating accusedPostponedAppealDate in limited access case service for case ${
theCase.id
}. Relevant info: ${JSON.stringify(relevantInfo)}`,
)
}

const [numberOfAffectedRows] = await this.caseModel.update(
{ ...update },
{ where: { id: theCase.id } },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,17 @@ export type CaseEvent =
| 'SCHEDULE_COURT_DATE'
| 'SUBPOENA_SERVICE_STATUS'

const caseEventsToLog = [
'CREATE',
'CREATE_XRD',
'SCHEDULE_COURT_DATE',
'SUBPOENA_SERVICE_STATUS',
'COMPLETE',
'ACCEPT',
'REJECT',
'DISMISS',
]

@Injectable()
export class EventService {
constructor(
Expand Down Expand Up @@ -159,6 +170,8 @@ export class EventService {
{ error },
)
}

this.logInfo(event, theCase)
unakb marked this conversation as resolved.
Show resolved Hide resolved
unakb marked this conversation as resolved.
Show resolved Hide resolved
}

async postErrorEvent(
Expand Down Expand Up @@ -210,4 +223,30 @@ export class EventService {

return infoText
}

logInfo = (event: CaseEvent, theCase: Case) => {
if (caseEventsToLog.indexOf(event) === -1) {
return
}

let extraInfo = ''

switch (event) {
case 'SCHEDULE_COURT_DATE':
extraInfo = `courtDate ${formatDate(
DateLog.courtDate(theCase.dateLogs)?.date ??
DateLog.arraignmentDate(theCase.dateLogs)?.date,
'Pp',
)}`
break
default:
break
}

this.logger.info(`Event ${event} for case ${theCase.id}`, {
caseId: theCase.id,
event,
extraInfo,
})
}
unakb marked this conversation as resolved.
Show resolved Hide resolved
unakb marked this conversation as resolved.
Show resolved Hide resolved
}
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,10 @@ export class SubpoenaService {
)
}

this.logger.info(
`Subpoena ${createdSubpoena.subpoenaId} delivered to police`,
)

return { delivered: true }
} catch (error) {
this.logger.error('Error delivering subpoena to police', error)
Expand Down
2 changes: 1 addition & 1 deletion apps/judicial-system/xrd-api/src/app/app.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export class AppController {
@Param('subpoenaId', new ParseUUIDPipe()) subpoenaId: string,
@Body() updateSubpoena: UpdateSubpoenaDto,
): Promise<SubpoenaResponse> {
this.logger.debug(`Updating subpoena for ${subpoenaId}`)
this.logger.info(`Updating subpoena ${subpoenaId}`)

return this.appService.updateSubpoena(subpoenaId, updateSubpoena)
}
Expand Down
Loading