Skip to content

Commit

Permalink
chore(j-s): Logging more info for system status (#16808)
Browse files Browse the repository at this point in the history
* chore(j-s): Logging more info for system status

* fix(j-s): Filtering case list to remove deleted indictments for digital mailbox

* Update event.service.ts

* Update event.service.ts

---------

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
  • Loading branch information
unakb and kodiakhq[bot] authored Nov 14, 2024
1 parent 9685529 commit 64ad820
Show file tree
Hide file tree
Showing 7 changed files with 51 additions and 37 deletions.
17 changes: 0 additions & 17 deletions apps/judicial-system/backend/src/app/modules/case/case.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1703,23 +1703,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
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 @@ -319,23 +319,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 @@ -152,6 +163,7 @@ export class EventService {
],
}),
})
this.logInfo(event, theCase)
} catch (error) {
// Tolerate failure, but log error
this.logger.error(
Expand Down Expand Up @@ -210,4 +222,30 @@ export class EventService {

return infoText
}

logInfo = (event: CaseEvent, theCase: Case) => {
if (!caseEventsToLog.includes(event)) {
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,
})
}
}
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

0 comments on commit 64ad820

Please sign in to comment.