Skip to content

Commit

Permalink
Merge branch 'main' into feat/getProviderAndType
Browse files Browse the repository at this point in the history
  • Loading branch information
GunnlaugurG committed May 27, 2024
2 parents 7ce7886 + e651c8b commit 01cc0cc
Show file tree
Hide file tree
Showing 137 changed files with 2,263 additions and 1,607 deletions.
26 changes: 26 additions & 0 deletions .yarn/patches/cache-manager-ioredis-yet-npm-1.1.0-da7d1a9865.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
diff --git a/dist/index.js b/dist/index.js
index 21d1ae2f70d7c5b38e17d053a9bf68454edfe98a..6045a01e347041e0cb0b7025dc5734d9f44a9bfb 100644
--- a/dist/index.js
+++ b/dist/index.js
@@ -90,7 +90,7 @@ function builder(redisCache, reset, keys, options) {
yield redisCache.del(key);
});
},
- ttl: (key) => __awaiter(this, void 0, void 0, function* () { return redisCache.ttl(key); }),
+ ttl: (key) => __awaiter(this, void 0, void 0, function* () { return redisCache.pttl(key); }),
keys: (pattern = '*') => keys(pattern),
reset,
isCacheable,
diff --git a/src/index.ts b/src/index.ts
index 267bdf152027f4bc6f0321c186542ce2dc5f3bb1..a295c85899f6206de13d202967e7676247925a53 100644
--- a/src/index.ts
+++ b/src/index.ts
@@ -87,7 +87,7 @@ function builder(
async del(key) {
await redisCache.del(key);
},
- ttl: async (key) => redisCache.ttl(key),
+ ttl: async (key) => redisCache.pttl(key),
keys: (pattern = '*') => keys(pattern),
reset,
isCacheable,
44 changes: 44 additions & 0 deletions .yarn/patches/dd-trace-npm-5.14.1-8d45ad14d6.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
diff --git a/packages/dd-trace/src/external-logger/src/index.js b/packages/dd-trace/src/external-logger/src/index.js
index aa21b20b6e78336329f8f99214a36fde3b9c2c59..523c285768a9f34ba9bc353a5caff6962cf1ff5c 100644
--- a/packages/dd-trace/src/external-logger/src/index.js
+++ b/packages/dd-trace/src/external-logger/src/index.js
@@ -81,7 +81,7 @@ class ExternalLogger {
let encodedLogs

if (!this.queue.length) {
- setImmediate(() => cb())
+ setTimeout(() => cb(), 0)
return
}

@@ -93,7 +93,7 @@ class ExternalLogger {
encodedLogs = JSON.stringify(logs)
} catch (error) {
tracerLogger.error(`failed to encode ${numLogs} logs`)
- setImmediate(() => cb(error))
+ setTimeout(() => cb(error), 0)
return
}

diff --git a/packages/dd-trace/src/telemetry/dependencies.js b/packages/dd-trace/src/telemetry/dependencies.js
index 992dde7d2ec7b6742b55e48bb0941f88d01669bf..9a0559d576663eaff4291edf0fdda6ea51da1456 100644
--- a/packages/dd-trace/src/telemetry/dependencies.js
+++ b/packages/dd-trace/src/telemetry/dependencies.js
@@ -32,7 +32,7 @@ function createBatchPayload (payload) {
}
function waitAndSend (config, application, host) {
if (!immediate) {
- immediate = setImmediate(() => {
+ immediate = setTimeout(() => {
immediate = null
if (savedDependenciesToSend.size > 0) {
const dependencies = Array.from(savedDependenciesToSend.values())
@@ -69,7 +69,7 @@ function waitAndSend (config, application, host) {
waitAndSend(config, application, host)
}
}
- })
+ }, 0)
immediate.unref()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ export class CaseListInterceptor implements NestInterceptor {
return next.handle().pipe(
map((cases: CaseListEntry[]) => {
return cases.map((theCase) => {
const indictmentInfo = getIndictmentInfo(
theCase.rulingDate,
theCase.type,
theCase.defendants,
)
return {
...theCase,
isValidToDateInThePast: theCase.validToDate
Expand All @@ -36,8 +41,7 @@ export class CaseListInterceptor implements NestInterceptor {
theCase.prosecutorPostponedAppealDate,
theCase.accusedPostponedAppealDate,
),
indictmentAppealDeadline: getIndictmentInfo(theCase.rulingDate)
.indictmentAppealDeadline,
...indictmentInfo,
}
})
}),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,4 +114,10 @@ export class CaseListEntry {

@Field(() => String, { nullable: true })
readonly indictmentAppealDeadline?: string

@Field(() => Boolean, { nullable: true })
readonly indictmentVerdictViewedByAll?: boolean

@Field(() => String, { nullable: true })
readonly indictmentVerdictAppealDeadline?: string
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
import {
CaseAppealDecision,
CaseType,
getStatementDeadline,
isIndictmentCase,
UserRole,
} from '@island.is/judicial-system/types'

import { Defendant } from '../../defendant'
import { Case } from '../models/case.model'

const getDays = (days: number) => days * 24 * 60 * 60 * 1000
Expand All @@ -21,6 +24,8 @@ interface AppealInfo {

interface IndictmentInfo {
indictmentAppealDeadline?: string
indictmentVerdictViewedByAll?: boolean
indictmentVerdictAppealDeadline?: string
}

const isAppealableDecision = (decision?: CaseAppealDecision | null) => {
Expand Down Expand Up @@ -91,10 +96,14 @@ export const getAppealInfo = (theCase: Case): AppealInfo => {
return appealInfo
}

export const getIndictmentInfo = (rulingDate?: string): IndictmentInfo => {
export const getIndictmentInfo = (
rulingDate?: string,
caseType?: CaseType,
defendants?: Defendant[],
): IndictmentInfo => {
const indictmentInfo: IndictmentInfo = {}

if (!rulingDate) {
if ((caseType && !isIndictmentCase(caseType)) || !rulingDate) {
return indictmentInfo
}

Expand All @@ -103,12 +112,64 @@ export const getIndictmentInfo = (rulingDate?: string): IndictmentInfo => {
theRulingDate.setDate(theRulingDate.getDate() + 28),
).toISOString()

if (defendants) {
const verdictViewDates = defendants?.map(
(defendant) => defendant.verdictViewDate,
)

if (!verdictViewDates || verdictViewDates?.some((date) => !date)) {
indictmentInfo.indictmentVerdictViewedByAll = false
} else {
indictmentInfo.indictmentVerdictViewedByAll = true
const newestViewDate = verdictViewDates
?.filter((date): date is string => date !== undefined)
.map((date) => new Date(date))
.reduce(
(newest, current) => (current > newest ? current : newest),
new Date(0),
)
const expiryDate = new Date(newestViewDate.getTime())
expiryDate.setDate(newestViewDate.getDate() + 28)

indictmentInfo.indictmentVerdictAppealDeadline = expiryDate.toISOString()
}
}

return indictmentInfo
}

const getDefendantsInfo = (
defendants: Defendant[] | undefined,
caseType?: CaseType,
) => {
if (!defendants || !isIndictmentCase(caseType)) {
return defendants
}

const expiryDays = getDays(28)

return defendants.map((defendant) => {
const { verdictViewDate } = defendant
return {
...defendant,
verdictAppealDeadline: verdictViewDate
? new Date(
new Date(verdictViewDate).getTime() + expiryDays,
).toISOString()
: undefined,
}
})
}

export const transformCase = (theCase: Case): Case => {
const appealInfo = getAppealInfo(theCase)
const indictmentInfo = getIndictmentInfo(theCase.rulingDate)
const indictmentInfo = getIndictmentInfo(
theCase.rulingDate,
theCase.type,
theCase.defendants,
)
const defendants = getDefendantsInfo(theCase.defendants, theCase.type)

return {
...theCase,
requestProsecutorOnlySession: theCase.requestProsecutorOnlySession ?? false,
Expand All @@ -129,6 +190,7 @@ export const transformCase = (theCase: Case): Case => {
? Date.now() >=
new Date(theCase.appealReceivedByCourtDate).getTime() + getDays(1)
: false,
defendants: defendants,
...appealInfo,
...indictmentInfo,
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -428,4 +428,10 @@ export class Case {

@Field(() => String, { nullable: true })
readonly indictmentAppealDeadline?: string

@Field(() => Boolean, { nullable: true })
readonly indictmentVerdictViewedByAll?: boolean

@Field(() => String, { nullable: true })
readonly indictmentVerdictAppealDeadline?: string
}
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,7 @@ export class Defendant {

@Field(() => String, { nullable: true })
readonly verdictViewDate?: string

@Field(() => String, { nullable: true })
readonly verdictAppealDeadline?: string
}
16 changes: 8 additions & 8 deletions apps/judicial-system/backend/src/app/messages/notifications.ts
Original file line number Diff line number Diff line change
Expand Up @@ -267,16 +267,16 @@ export const notifications = {
'Notaður sem nafn á þingbókarviðhengi í pósti til hagaðila vegna undirritunar úrskurðar',
},
prosecutorBodyS3: {
id: 'judicial.system.backend:notifications.signed_ruling.prosecutor_body_s3_v2',
id: 'judicial.system.backend:notifications.signed_ruling.prosecutor_body_s3_v3',
defaultMessage:
'Dómari hefur {isModifyingRuling, select, true {leiðrétt} other {undirritað og staðfest}} úrskurð í máli {courtCaseNumber} hjá {courtName}.<br /><br />Skjöl málsins eru aðengileg á {linkStart}yfirlitssíðu málsins í Réttarvörslugátt{linkEnd}.',
'Dómari hefur {isModifyingRuling, select, true {leiðrétt} other {undirritað og staðfest}} úrskurð í máli {courtCaseNumber} hjá {courtName}.<br /><br />Skjöl málsins eru aðgengileg á {linkStart}yfirlitssíðu málsins í Réttarvörslugátt{linkEnd}.',
description:
'Notaður sem texti í pósti til sækjanda vegna undirritunar úrskurðar ef tókst að vista úrskurð í AWS S3',
},
courtBody: {
id: 'judicial.system.backend:notifications.signed_ruling.court_body',
id: 'judicial.system.backend:notifications.signed_ruling.court_body_v1',
defaultMessage:
'Ekki tókst að vista þingbók og/eða úrskurð í máli {courtCaseNumber} í Auði.<br /><br />Skjöl málsins eru aðengileg á {linkStart}yfirlitssíðu málsins í Réttarvörslugátt{linkEnd}.',
'Ekki tókst að vista þingbók og/eða úrskurð í máli {courtCaseNumber} í Auði.<br /><br />Skjöl málsins eru aðgengileg á {linkStart}yfirlitssíðu málsins í Réttarvörslugátt{linkEnd}.',
description:
'Notaður sem texti í pósti til dómara og dómritara vegna undirritunar úrskurðar ef ekki tókst að vista þingbók eða úrskurð í Auði',
},
Expand All @@ -303,16 +303,16 @@ export const notifications = {
'Notaður sem titill í pósti til hagaðila vegna staðfests dóms',
},
prosecutorBody: {
id: 'judicial.system.backend:notifications.case_completed.prosecutor_body_v1',
id: 'judicial.system.backend:notifications.case_completed.prosecutor_body_v2',
defaultMessage:
'Máli {courtCaseNumber} hjá {courtName} hefur verið lokið.<br /><br />Niðurstaða: {caseIndictmentRulingDecision}<br /><br />Skjöl málsins eru aðengileg á {linkStart}yfirlitssíðu málsins í Réttarvörslugátt{linkEnd}.',
'Máli {courtCaseNumber} hjá {courtName} hefur verið lokið.<br /><br />Niðurstaða: {caseIndictmentRulingDecision}<br /><br />Skjöl málsins eru aðgengileg á {linkStart}yfirlitssíðu málsins í Réttarvörslugátt{linkEnd}.',
description:
'Notaður sem texti í pósti til sækjanda vegna staðfests dóms',
},
defenderBody: {
id: 'judicial.system.backend:notifications.case_completed.defender_body_v3',
id: 'judicial.system.backend:notifications.case_completed.defender_body_v4',
defaultMessage:
'Máli {courtCaseNumber} hjá {courtName} hefur verið lokið.<br /><br />Niðurstaða: {caseIndictmentRulingDecision}<br /><br />{defenderHasAccessToRvg, select, false {Þú getur nálgast gögn málsins hjá {courtName} ef þau hafa ekki þegar verið afhent} other {Þú getur nálgast gögn málsins á {linkStart}yfirlitssíðu málsins í Réttarvörslugátt{linkEnd}}}.',
'Máli {courtCaseNumber} hjá {courtName} hefur verið lokið.<br /><br />Niðurstaða: {caseIndictmentRulingDecision}<br /><br />{defenderHasAccessToRvg, select, false {Þú getur nálgast gögn málsins hjá {courtName} ef þau hafa ekki þegar verið afhent} other {Skjöl málsins eru aðgengileg á {linkStart}yfirlitssíðu málsins í Réttarvörslugátt{linkEnd}.}}.',
description:
'Notaður sem texti í pósti til verjanda vegna staðfests dóms',
},
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { IsNotEmpty, IsString } from 'class-validator'

import { ApiProperty } from '@nestjs/swagger'

export class InternalCasesDto {
@IsNotEmpty()
@IsString()
@ApiProperty({ type: String })
readonly nationalId!: string
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import type { Logger } from '@island.is/logging'
import { LOGGER_PROVIDER } from '@island.is/logging'

import { TokenGuard } from '@island.is/judicial-system/auth'
import { formatNationalId } from '@island.is/judicial-system/formatters'
import {
messageEndpoint,
MessageType,
Expand All @@ -25,6 +26,7 @@ import {

import { CaseEvent, EventService } from '../event'
import { DeliverDto } from './dto/deliver.dto'
import { InternalCasesDto } from './dto/internalCases.dto'
import { InternalCreateCaseDto } from './dto/internalCreateCase.dto'
import { CurrentCase } from './guards/case.decorator'
import { CaseCompletedGuard } from './guards/caseCompleted.guard'
Expand Down Expand Up @@ -68,6 +70,21 @@ export class InternalCaseController {
return this.internalCaseService.archive()
}

@Post('cases/indictments')
@ApiOkResponse({
type: Case,
isArray: true,
description: 'Gets all indictment cases',
})
getIndictmentCases(
@Body() internalCasesDto: InternalCasesDto,
): Promise<Case[]> {
this.logger.debug('Getting all indictment cases')
const nationalId = formatNationalId(internalCasesDto.nationalId)

return this.internalCaseService.getIndictmentCases(nationalId)
}

@UseGuards(CaseExistsGuard)
@Post(
`case/:caseId/${messageEndpoint[MessageType.DELIVERY_TO_COURT_PROSECUTOR]}`,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ import { archiveFilter } from './filters/case.archiveFilter'
import { ArchiveResponse } from './models/archive.response'
import { Case } from './models/case.model'
import { CaseArchive } from './models/caseArchive.model'
import { DateLog } from './models/dateLog.model'
import { DeliverResponse } from './models/deliver.response'
import { caseModuleConfig } from './case.config'

Expand Down Expand Up @@ -1151,4 +1152,19 @@ export class InternalCaseService {

return originalAncestor
}

async getIndictmentCases(nationalId: string): Promise<Case[]> {
return this.caseModel.findAll({
include: [
{ model: Defendant, as: 'defendants' },
{ model: DateLog, as: 'dateLogs' },
],
order: [[{ model: DateLog, as: 'dateLogs' }, 'created', 'DESC']],
attributes: ['id', 'courtCaseNumber', 'type', 'state'],
where: {
type: CaseType.INDICTMENT,
'$defendants.national_id$': nationalId,
},
})
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ describe('InternalNotificationController - Send ruling notifications', () => {
expect.objectContaining({
to: [{ name: prosecutor.name, address: prosecutor.email }],
subject: 'Máli lokið 007-2022-07',
html: `Máli 007-2022-07 hjá Héraðsdómi Reykjavíkur hefur verið lokið.<br /><br />Niðurstaða: Ekki skráð<br /><br />Skjöl málsins eru aðengileg á ${expectedLink}yfirlitssíðu málsins í Réttarvörslugátt</a>.`,
html: `Máli 007-2022-07 hjá Héraðsdómi Reykjavíkur hefur verið lokið.<br /><br />Niðurstaða: Ekki skráð<br /><br />Skjöl málsins eru aðgengileg á ${expectedLink}yfirlitssíðu málsins í Réttarvörslugátt</a>.`,
}),
)
})
Expand Down Expand Up @@ -138,7 +138,7 @@ describe('InternalNotificationController - Send ruling notifications', () => {
expect.objectContaining({
to: [{ name: prosecutor.name, address: prosecutor.email }],
subject: 'Úrskurður í máli 007-2022-07',
html: `Dómari hefur undirritað og staðfest úrskurð í máli 007-2022-07 hjá Héraðsdómi Reykjavíkur.<br /><br />Skjöl málsins eru aðengileg á ${expectedLink}yfirlitssíðu málsins í Réttarvörslugátt</a>.`,
html: `Dómari hefur undirritað og staðfest úrskurð í máli 007-2022-07 hjá Héraðsdómi Reykjavíkur.<br /><br />Skjöl málsins eru aðgengileg á ${expectedLink}yfirlitssíðu málsins í Réttarvörslugátt</a>.`,
}),
)
})
Expand Down Expand Up @@ -169,7 +169,7 @@ describe('InternalNotificationController - Send ruling notifications', () => {
expect.objectContaining({
to: [{ name: prosecutor.name, address: prosecutor.email }],
subject: 'Úrskurður í máli 007-2022-07 leiðréttur',
html: `Dómari hefur leiðrétt úrskurð í máli 007-2022-07 hjá Héraðsdómi Reykjavíkur.<br /><br />Skjöl málsins eru aðengileg á ${expectedLink}yfirlitssíðu málsins í Réttarvörslugátt</a>.`,
html: `Dómari hefur leiðrétt úrskurð í máli 007-2022-07 hjá Héraðsdómi Reykjavíkur.<br /><br />Skjöl málsins eru aðgengileg á ${expectedLink}yfirlitssíðu málsins í Réttarvörslugátt</a>.`,
}),
)
})
Expand Down
Loading

0 comments on commit 01cc0cc

Please sign in to comment.