Repository: island-is/island.is
Pull request #18836: fix(j-s): rename subpoenaId to policeSubpoenaId
Author: login: thorhildurt
Created: 2025-04-22T15:51:45Z | Merged: 2025-04-25T15:19:30Z

# [Rename subpoenaId to policeSubpoenaId](https://app.asana.com/1/203394141643832/project/1199153462262248/task/1209431684853011)

## What
- Rename `subpoenaId` to `policeSubpoenaId` to avoid confusing `subpoena.subpoenaId` and `subpoena.id`

## Why
- we use `subpoenaId` all over the place for the `subpoenaId` and we have made one bug on mixing id with police subpoena id, so we rename it to make it more clear

## Checklist:

- [ ] I have performed a self-review of my own code
- [ ] I have made corresponding changes to the documentation
- [ ] My changes generate no new warnings
- [ ] I have added tests that prove my fix is effective or that my feature works
- [ ] Formatting passes locally with my changes
- [ ] I have rebased against main before asking for a review


<!-- This is an auto-generated comment: release notes by coderabbit.ai -->
## Summary by CodeRabbit

- **Refactor**
  - Renamed the subpoena identifier field from subpoenaId to policeSubpoenaId across the system for improved clarity and consistency.
  - Updated API endpoints, service methods, GraphQL queries, and UI components to use policeSubpoenaId.
  - Modified database schema and migration scripts to reflect the new field name.
- **Bug Fixes**
  - Corrected validation and guard logic to use policeSubpoenaId, ensuring accurate data retrieval and error handling.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->


Diff:
diff --git a/apps/judicial-system/api/src/app/modules/subpoena/models/subpoena.model.ts b/apps/judicial-system/api/src/app/modules/subpoena/models/subpoena.model.ts
index 2bd991c2d4d8..f3a2d4c1baa3 100644
--- a/apps/judicial-system/api/src/app/modules/subpoena/models/subpoena.model.ts
+++ b/apps/judicial-system/api/src/app/modules/subpoena/models/subpoena.model.ts
@@ -16,7 +16,7 @@ export class Subpoena {
   modified?: string
 
   @Field(() => String, { nullable: true })
-  subpoenaId?: string
+  policeSubpoenaId?: string
 
   @Field(() => String, { nullable: true })
   defendantId?: string
diff --git a/apps/judicial-system/backend/migrations/20250422152214-update-supoena-id.js b/apps/judicial-system/backend/migrations/20250422152214-update-supoena-id.js
new file mode 100644
index 000000000000..18504f0a3031
--- /dev/null
+++ b/apps/judicial-system/backend/migrations/20250422152214-update-supoena-id.js
@@ -0,0 +1,33 @@
+'use strict'
+
+module.exports = {
+  up: (queryInterface) => {
+    return queryInterface.sequelize.transaction((t) =>
+      Promise.all([
+        queryInterface.renameColumn(
+          'subpoena',
+          'subpoena_id',
+          'police_subpoena_id',
+          {
+            transaction: t,
+          },
+        ),
+      ]),
+    )
+  },
+
+  down: (queryInterface) => {
+    return queryInterface.sequelize.transaction((t) =>
+      Promise.all([
+        queryInterface.renameColumn(
+          'subpoena',
+          'police_subpoena_id',
+          'subpoena_id',
+          {
+            transaction: t,
+          },
+        ),
+      ]),
+    )
+  },
+}
diff --git a/apps/judicial-system/backend/src/app/modules/police/models/createSubpoena.response.ts b/apps/judicial-system/backend/src/app/modules/police/models/createSubpoena.response.ts
index d480c70a4271..74c9f903edce 100644
--- a/apps/judicial-system/backend/src/app/modules/police/models/createSubpoena.response.ts
+++ b/apps/judicial-system/backend/src/app/modules/police/models/createSubpoena.response.ts
@@ -2,5 +2,5 @@ import { ApiProperty } from '@nestjs/swagger'
 
 export class CreateSubpoenaResponse {
   @ApiProperty({ type: String })
-  subpoenaId!: string
+  policeSubpoenaId!: string
 }
diff --git a/apps/judicial-system/backend/src/app/modules/police/police.service.ts b/apps/judicial-system/backend/src/app/modules/police/police.service.ts
index 5d69816fe575..1189f978897c 100644
--- a/apps/judicial-system/backend/src/app/modules/police/police.service.ts
+++ b/apps/judicial-system/backend/src/app/modules/police/police.service.ts
@@ -345,11 +345,11 @@ export class PoliceService {
   }
 
   async getSubpoenaStatus(
-    subpoenaId: string,
+    policeSubpoenaId: string,
     user?: User,
   ): Promise<SubpoenaInfo> {
     return this.fetchPoliceDocumentApi(
-      `${this.xRoadPath}/GetSubpoenaStatus?id=${subpoenaId}`,
+      `${this.xRoadPath}/GetSubpoenaStatus?id=${policeSubpoenaId}`,
     )
       .then(async (res: Response) => {
         if (res.ok) {
@@ -383,7 +383,7 @@ export class PoliceService {
         // The police system does not provide a structured error response.
         // When a subpoena does not exist, a stack trace is returned.
         throw new NotFoundException({
-          message: `Subpoena with id ${subpoenaId} does not exist`,
+          message: `Subpoena with police subpoena id ${policeSubpoenaId} does not exist`,
           detail: reason,
         })
       })
@@ -396,7 +396,7 @@ export class PoliceService {
           // Act as if the subpoena does not exist
           throw new NotFoundException({
             ...reason,
-            message: `Subpoena ${subpoenaId} does not exist`,
+            message: `Subpoena ${policeSubpoenaId} does not exist`,
             detail: reason.message,
           })
         }
@@ -404,7 +404,7 @@ export class PoliceService {
         this.eventService.postErrorEvent(
           'Failed to get subpoena',
           {
-            subpoenaId,
+            policeSubpoenaId,
             actor: user?.name || 'Digital-mailbox',
             institution: user?.institution?.name,
           },
@@ -413,7 +413,7 @@ export class PoliceService {
 
         throw new BadGatewayException({
           ...reason,
-          message: `Failed to get subpoena ${subpoenaId}`,
+          message: `Failed to get subpoena ${policeSubpoenaId}`,
           detail: reason.message,
         })
       })
@@ -663,7 +663,7 @@ export class PoliceService {
 
       if (res.ok) {
         const subpoenaResponse = await res.json()
-        return { subpoenaId: subpoenaResponse.id }
+        return { policeSubpoenaId: subpoenaResponse.id }
       }
 
       throw await res.text()
@@ -688,14 +688,14 @@ export class PoliceService {
 
   async revokeSubpoena(
     theCase: Case,
-    subpoenaId: string,
+    policeSubpoenaId: string,
     user: User,
   ): Promise<boolean> {
     const { name: actor } = user
 
     try {
       const res = await this.fetchPoliceCaseApi(
-        `${this.xRoadPath}/InvalidateCourtSummon?sekGuid=${subpoenaId}`,
+        `${this.xRoadPath}/InvalidateCourtSummon?sekGuid=${policeSubpoenaId}`,
         {
           method: 'POST',
           headers: {
@@ -714,7 +714,7 @@ export class PoliceService {
       throw await res.text()
     } catch (error) {
       this.logger.error(
-        `Failed revoke subpoena with id ${subpoenaId} for case ${theCase.id} from police`,
+        `Failed revoke subpoena with police subpoena id ${policeSubpoenaId} for case ${theCase.id} from police`,
         {
           error,
         },
@@ -724,7 +724,7 @@ export class PoliceService {
         'Failed to revoke subpoena from police',
         {
           caseId: theCase.id,
-          subpoenaId,
+          policeSubpoenaId,
           actor,
         },
         error,
diff --git a/apps/judicial-system/backend/src/app/modules/subpoena/guards/policeSubpoenaExists.guard.ts b/apps/judicial-system/backend/src/app/modules/subpoena/guards/policeSubpoenaExists.guard.ts
index e351570b9714..d47983971362 100644
--- a/apps/judicial-system/backend/src/app/modules/subpoena/guards/policeSubpoenaExists.guard.ts
+++ b/apps/judicial-system/backend/src/app/modules/subpoena/guards/policeSubpoenaExists.guard.ts
@@ -14,14 +14,16 @@ export class PoliceSubpoenaExistsGuard implements CanActivate {
   async canActivate(context: ExecutionContext): Promise<boolean> {
     const request = context.switchToHttp().getRequest()
 
-    const subpoenaId = request.params.subpoenaId
+    const policeSubpoenaId = request.params.policeSubpoenaId
 
-    if (!subpoenaId) {
+    if (!policeSubpoenaId) {
       throw new BadRequestException('Missing police subpoena id')
     }
 
-    // subpoenaId is the external police document id
-    request.subpoena = await this.subpoenaService.findBySubpoenaId(subpoenaId)
+    // policeSubpoenaId is the external police document id
+    request.subpoena = await this.subpoenaService.findByPoliceSubpoenaId(
+      policeSubpoenaId,
+    )
 
     return true
   }
diff --git a/apps/judicial-system/backend/src/app/modules/subpoena/guards/test/policeSubpoenaExistsGuard.spec.ts b/apps/judicial-system/backend/src/app/modules/subpoena/guards/test/policeSubpoenaExistsGuard.spec.ts
index c924bb6a938f..f9d6ee180957 100644
--- a/apps/judicial-system/backend/src/app/modules/subpoena/guards/test/policeSubpoenaExistsGuard.spec.ts
+++ b/apps/judicial-system/backend/src/app/modules/subpoena/guards/test/policeSubpoenaExistsGuard.spec.ts
@@ -48,9 +48,9 @@ describe('Police Subpoena Exists Guard', () => {
 
   describe('subpoena exists', () => {
     const policeSubpoenaId = uuid()
-    const subpoena = { id: uuid(), subpoenaId: policeSubpoenaId }
+    const subpoena = { id: uuid(), policeSubpoenaId }
     const request = {
-      params: { subpoenaId: policeSubpoenaId },
+      params: { policeSubpoenaId },
       subpoena: undefined,
     }
     let then: Then
@@ -66,7 +66,7 @@ describe('Police Subpoena Exists Guard', () => {
     it('should activate', () => {
       expect(mockSubpoenaModel.findOne).toHaveBeenCalledWith({
         include,
-        where: { subpoenaId: policeSubpoenaId },
+        where: { policeSubpoenaId },
       })
       expect(then.result).toBe(true)
       expect(request.subpoena).toBe(subpoena)
@@ -79,7 +79,7 @@ describe('Police Subpoena Exists Guard', () => {
 
     beforeEach(async () => {
       mockRequest.mockReturnValueOnce({
-        params: { subpoenaId: policeSubpoenaId },
+        params: { policeSubpoenaId },
       })
 
       then = await givenWhenThen()
diff --git a/apps/judicial-system/backend/src/app/modules/subpoena/internalSubpoena.controller.ts b/apps/judicial-system/backend/src/app/modules/subpoena/internalSubpoena.controller.ts
index 636858a361fe..54a53b9016aa 100644
--- a/apps/judicial-system/backend/src/app/modules/subpoena/internalSubpoena.controller.ts
+++ b/apps/judicial-system/backend/src/app/modules/subpoena/internalSubpoena.controller.ts
@@ -48,13 +48,13 @@ export class InternalSubpoenaController {
   ) {}
 
   @UseGuards(PoliceSubpoenaExistsGuard)
-  @Patch('subpoena/:subpoenaId')
+  @Patch('subpoena/:policeSubpoenaId')
   updateSubpoena(
-    @Param('subpoenaId') subpoenaId: string,
+    @Param('policeSubpoenaId') policeSubpoenaId: string,
     @CurrentSubpoena() subpoena: Subpoena,
     @Body() update: UpdateSubpoenaDto,
   ): Promise<Subpoena> {
-    this.logger.debug(`Updating subpoena by subpoena id ${subpoenaId}`)
+    this.logger.debug(`Updating subpoena by police subpoena id ${policeSubpoenaId}`)
 
     return this.subpoenaService.update(subpoena, update)
   }
@@ -96,7 +96,7 @@ export class InternalSubpoenaController {
         deliveredToPolice: results.delivered,
         subpoenaId: subpoena.id,
         subpoenaCreated: subpoena.created,
-        policeSubpoenaId: currentSubpoena.subpoenaId,
+        policeSubpoenaId: currentSubpoena.policeSubpoenaId,
         subpoenaHash: currentSubpoena.hash,
         subpoenaDeliveredToPolice: new Date(),
         indictmentHash: theCase.indictmentHash,
diff --git a/apps/judicial-system/backend/src/app/modules/subpoena/models/subpoena.model.ts b/apps/judicial-system/backend/src/app/modules/subpoena/models/subpoena.model.ts
index 3a67a4b166be..fd2fc8b55a1f 100644
--- a/apps/judicial-system/backend/src/app/modules/subpoena/models/subpoena.model.ts
+++ b/apps/judicial-system/backend/src/app/modules/subpoena/models/subpoena.model.ts
@@ -54,7 +54,7 @@ export class Subpoena extends Model {
 
   @ApiPropertyOptional({ type: String })
   @Column({ type: DataType.STRING, allowNull: true })
-  subpoenaId?: string
+  policeSubpoenaId?: string
 
   @ForeignKey(() => Defendant)
   @Column({ type: DataType.UUID, allowNull: false })
diff --git a/apps/judicial-system/backend/src/app/modules/subpoena/subpoena.service.ts b/apps/judicial-system/backend/src/app/modules/subpoena/subpoena.service.ts
index 5bf37f2f2dc0..f98bff91811a 100644
--- a/apps/judicial-system/backend/src/app/modules/subpoena/subpoena.service.ts
+++ b/apps/judicial-system/backend/src/app/modules/subpoena/subpoena.service.ts
@@ -286,10 +286,10 @@ export class SubpoenaService {
     return subpoena
   }
 
-  async findBySubpoenaId(policeSubpoenaId?: string): Promise<Subpoena> {
+  async findByPoliceSubpoenaId(policeSubpoenaId?: string): Promise<Subpoena> {
     const subpoena = await this.subpoenaModel.findOne({
       include,
-      where: { subpoenaId: policeSubpoenaId },
+      where: { policeSubpoenaId },
     })
 
     if (!subpoena) {
@@ -353,7 +353,7 @@ export class SubpoenaService {
       }
 
       const [numberOfAffectedRows] = await this.subpoenaModel.update(
-        { subpoenaId: createdSubpoena.subpoenaId },
+        { policeSubpoenaId: createdSubpoena.policeSubpoenaId },
         { where: { id: subpoena.id } },
       )
 
@@ -364,7 +364,7 @@ export class SubpoenaService {
       }
 
       this.logger.info(
-        `Subpoena ${createdSubpoena.subpoenaId} delivered to the police centralized file service`,
+        `Subpoena with police subpoena id ${createdSubpoena.policeSubpoenaId} delivered to the police centralized file service`,
       )
 
       return { delivered: true }
@@ -486,7 +486,7 @@ export class SubpoenaService {
     subpoena: Subpoena,
     user: TUser,
   ): Promise<DeliverResponse> {
-    if (!subpoena.subpoenaId) {
+    if (!subpoena.policeSubpoenaId) {
       this.logger.warn(
         `Attempted to revoke a subpoena with id ${subpoena.id} that had not been delivered to the police`,
       )
@@ -495,13 +495,13 @@ export class SubpoenaService {
 
     const subpoenaRevoked = await this.policeService.revokeSubpoena(
       theCase,
-      subpoena.subpoenaId,
+      subpoena.policeSubpoenaId,
       user,
     )
 
     if (subpoenaRevoked) {
       this.logger.info(
-        `Subpoena ${subpoena.subpoenaId} successfully revoked from police`,
+        `Subpoena ${subpoena.policeSubpoenaId} successfully revoked from police`,
       )
       return { delivered: true }
     } else {
@@ -510,7 +510,7 @@ export class SubpoenaService {
   }
 
   async getSubpoena(subpoena: Subpoena, user?: TUser): Promise<Subpoena> {
-    if (!subpoena.subpoenaId) {
+    if (!subpoena.policeSubpoenaId) {
       // The subpoena has not been delivered to the police
       return subpoena
     }
@@ -523,7 +523,7 @@ export class SubpoenaService {
     // We don't know if the subpoena has been served to the defendant
     // so we need to check the police service
     const subpoenaInfo = await this.policeService.getSubpoenaStatus(
-      subpoena.subpoenaId,
+      subpoena.policeSubpoenaId,
       user,
     )
 
diff --git a/apps/judicial-system/backend/src/app/modules/subpoena/test/internalSubpoenaController/deliverSubpoenaRevocationToPolice.spec.ts b/apps/judicial-system/backend/src/app/modules/subpoena/test/internalSubpoenaController/deliverSubpoenaRevocationToPolice.spec.ts
index d91c960cacde..6b1048cb7560 100644
--- a/apps/judicial-system/backend/src/app/modules/subpoena/test/internalSubpoenaController/deliverSubpoenaRevocationToPolice.spec.ts
+++ b/apps/judicial-system/backend/src/app/modules/subpoena/test/internalSubpoenaController/deliverSubpoenaRevocationToPolice.spec.ts
@@ -20,7 +20,7 @@ describe('InternalSubpoenaController - Deliver subpoena revocation to police', (
   const policeSubpoenaId = uuid()
   const defendantId = uuid()
 
-  const subpoena = { id: subpoenaId, subpoenaId: policeSubpoenaId } as Subpoena
+  const subpoena = { id: subpoenaId, policeSubpoenaId } as Subpoena
   const theCase = { id: caseId } as Case
 
   const userId = uuid()
diff --git a/apps/judicial-system/web/src/components/FormProvider/case.graphql b/apps/judicial-system/web/src/components/FormProvider/case.graphql
index 327b69879f06..793832154f40 100644
--- a/apps/judicial-system/web/src/components/FormProvider/case.graphql
+++ b/apps/judicial-system/web/src/components/FormProvider/case.graphql
@@ -50,7 +50,7 @@ query Case($input: CaseQueryInput!) {
         defenderNationalId
         caseId
         defendantId
-        subpoenaId
+        policeSubpoenaId
       }
     }
     defenderName
@@ -369,7 +369,7 @@ query Case($input: CaseQueryInput!) {
           comment
           defenderNationalId
           caseId
-          subpoenaId
+          policeSubpoenaId
         }
       }
       caseFiles {
diff --git a/apps/judicial-system/web/src/components/FormProvider/limitedAccessCase.graphql b/apps/judicial-system/web/src/components/FormProvider/limitedAccessCase.graphql
index ca1d1ea8a4f6..01fc17cd42ae 100644
--- a/apps/judicial-system/web/src/components/FormProvider/limitedAccessCase.graphql
+++ b/apps/judicial-system/web/src/components/FormProvider/limitedAccessCase.graphql
@@ -62,7 +62,7 @@ query LimitedAccessCase($input: CaseQueryInput!) {
         defenderNationalId
         caseId
         defendantId
-        subpoenaId
+        policeSubpoenaId
       }
     }
     defenderName
diff --git a/apps/judicial-system/web/src/routes/Defender/Cases/defenderCases.graphql b/apps/judicial-system/web/src/routes/Defender/Cases/defenderCases.graphql
index 2b0e43b45911..a81635be67a4 100644
--- a/apps/judicial-system/web/src/routes/Defender/Cases/defenderCases.graphql
+++ b/apps/judicial-system/web/src/routes/Defender/Cases/defenderCases.graphql
@@ -26,7 +26,7 @@ query DefenderCases($input: CaseListQueryInput) {
       subpoenas {
         id
         serviceStatus
-        subpoenaId
+        policeSubpoenaId
       }
     }
     initialRulingDate
diff --git a/apps/judicial-system/web/src/routes/Shared/Cases/cases.graphql b/apps/judicial-system/web/src/routes/Shared/Cases/cases.graphql
index 2fd3626fed7c..c0f6eb0dff00 100644
--- a/apps/judicial-system/web/src/routes/Shared/Cases/cases.graphql
+++ b/apps/judicial-system/web/src/routes/Shared/Cases/cases.graphql
@@ -34,7 +34,7 @@ query Cases {
       subpoenas {
         id
         serviceStatus
-        subpoenaId
+        policeSubpoenaId
       }
       verdictAppealDate
     }
diff --git a/apps/judicial-system/web/src/utils/hooks/useSubpoena/index.ts b/apps/judicial-system/web/src/utils/hooks/useSubpoena/index.ts
index cbf203ac1e9e..f50a82685a32 100644
--- a/apps/judicial-system/web/src/utils/hooks/useSubpoena/index.ts
+++ b/apps/judicial-system/web/src/utils/hooks/useSubpoena/index.ts
@@ -7,7 +7,8 @@ const useSubpoena = (subpoena: Subpoena) => {
   // Skip if the subpoena has not been sent to the police
   // or if the subpoena already has a service status
   const skip =
-    !subpoena.subpoenaId || isSuccessfulServiceStatus(subpoena.serviceStatus)
+    !subpoena.policeSubpoenaId ||
+    isSuccessfulServiceStatus(subpoena.serviceStatus)
 
   const { data, loading, error } = useSubpoenaQuery({
     skip,
diff --git a/apps/judicial-system/web/src/utils/hooks/useSubpoena/subpoena.graphql b/apps/judicial-system/web/src/utils/hooks/useSubpoena/subpoena.graphql
index 745293ed61eb..034562b15d42 100644
--- a/apps/judicial-system/web/src/utils/hooks/useSubpoena/subpoena.graphql
+++ b/apps/judicial-system/web/src/utils/hooks/useSubpoena/subpoena.graphql
@@ -9,6 +9,6 @@ query Subpoena($input: SubpoenaQueryInput!) {
     defenderNationalId
     caseId
     defendantId
-    subpoenaId
+    policeSubpoenaId
   }
 }
diff --git a/apps/judicial-system/xrd-api/src/app/app.controller.ts b/apps/judicial-system/xrd-api/src/app/app.controller.ts
index 673e514f71cd..9f15f90bffb7 100644
--- a/apps/judicial-system/xrd-api/src/app/app.controller.ts
+++ b/apps/judicial-system/xrd-api/src/app/app.controller.ts
@@ -71,15 +71,16 @@ export class AppController {
     }
   }
 
-  @Patch('subpoena/:subpoenaId')
+  // update by police subpoena id
+  @Patch('subpoena/:policeSubpoenaId')
   @ApiResponse({ status: 400, description: 'Invalid input' })
   @ApiResponse({ status: 502, description: 'Failed to update subpoena' })
   async updateSubpoena(
-    @Param('subpoenaId', new ParseUUIDPipe()) subpoenaId: string,
+    @Param('policeSubpoenaId', new ParseUUIDPipe()) policeSubpoenaId: string,
     @Body() updateSubpoena: UpdateSubpoenaDto,
   ): Promise<SubpoenaResponse> {
-    this.logger.info(`Updating subpoena ${subpoenaId}`)
+    this.logger.info(`Updating subpoena ${policeSubpoenaId}`)
 
-    return this.appService.updateSubpoena(subpoenaId, updateSubpoena)
+    return this.appService.updateSubpoena(policeSubpoenaId, updateSubpoena)
   }
 }
diff --git a/apps/judicial-system/xrd-api/src/app/app.service.ts b/apps/judicial-system/xrd-api/src/app/app.service.ts
index ff173fdfce4b..82d25dc8ea11 100644
--- a/apps/judicial-system/xrd-api/src/app/app.service.ts
+++ b/apps/judicial-system/xrd-api/src/app/app.service.ts
@@ -81,19 +81,19 @@ export class AppService {
   }
 
   async updateSubpoena(
-    subpoenaId: string,
+    policeSubpoenaId: string,
     updateSubpoena: UpdateSubpoenaDto,
   ): Promise<SubpoenaResponse> {
     return await this.auditTrailService.audit(
       'digital-mailbox-api',
       AuditedAction.UPDATE_SUBPOENA,
-      this.updateSubpoenaInfo(subpoenaId, updateSubpoena),
-      subpoenaId,
+      this.updateSubpoenaInfo(policeSubpoenaId, updateSubpoena),
+      policeSubpoenaId,
     )
   }
 
   private async updateSubpoenaInfo(
-    subpoenaId: string,
+    policeSubpoenaId: string,
     updateSubpoena: UpdateSubpoenaDto,
   ): Promise<SubpoenaResponse> {
     let defenderInfo: {
@@ -166,7 +166,7 @@ export class AppService {
 
     try {
       const res = await fetch(
-        `${this.config.backend.url}/api/internal/subpoena/${subpoenaId}`,
+        `${this.config.backend.url}/api/internal/subpoena/${policeSubpoenaId}`,
         {
           method: 'PATCH',
           headers: {


Reviews:
user: login: coderabbitai[bot]
body: **Actionable comments posted: 0**

<details>
<summary>🧹 Nitpick comments (1)</summary><blockquote>

<details>
<summary>apps/judicial-system/backend/migrations/20250422152214-update-supoena-id.js (1)</summary><blockquote>

`1-3`: **Remove redundant 'use strict' directive**

JavaScript modules are automatically in strict mode, making this directive unnecessary.

```diff
-'use strict'

 module.exports = {
```

<details>
<summary>🧰 Tools</summary>

<details>
<summary>🪛 Biome (1.9.4)</summary>

[error] 1-1: Redundant use strict directive.

The entire contents of JavaScript modules are automatically in strict mode, with no statement needed to initiate it.
Safe fix: Remove the redundant use strict directive.


(lint/suspicious/noRedundantUseStrict)

</details>

</details>

</blockquote></details>

</blockquote></details>

<details>
<summary>📜 Review details</summary>

**Configuration used: .coderabbit.yaml**
**Review profile: CHILL**
**Plan: Pro**

<details>
<summary>📥 Commits</summary>

Reviewing files that changed from the base of the PR and between 20d7c28117e9ef59e14977a2c985ff474db76ee4 and 04b650bd0a44e232855f174f5f1109a886fe0c58.

</details>

<details>
<summary>📒 Files selected for processing (14)</summary>

* `apps/judicial-system/api/src/app/modules/subpoena/models/subpoena.model.ts` (1 hunks)
* `apps/judicial-system/backend/migrations/20250422152214-update-supoena-id.js` (1 hunks)
* `apps/judicial-system/backend/src/app/modules/police/models/createSubpoena.response.ts` (1 hunks)
* `apps/judicial-system/backend/src/app/modules/police/police.service.ts` (1 hunks)
* `apps/judicial-system/backend/src/app/modules/subpoena/guards/policeSubpoenaExists.guard.ts` (1 hunks)
* `apps/judicial-system/backend/src/app/modules/subpoena/internalSubpoena.controller.ts` (1 hunks)
* `apps/judicial-system/backend/src/app/modules/subpoena/models/subpoena.model.ts` (1 hunks)
* `apps/judicial-system/backend/src/app/modules/subpoena/subpoena.service.ts` (7 hunks)
* `apps/judicial-system/web/src/components/FormProvider/case.graphql` (2 hunks)
* `apps/judicial-system/web/src/components/FormProvider/limitedAccessCase.graphql` (1 hunks)
* `apps/judicial-system/web/src/routes/Defender/Cases/defenderCases.graphql` (1 hunks)
* `apps/judicial-system/web/src/routes/Shared/Cases/cases.graphql` (1 hunks)
* `apps/judicial-system/web/src/utils/hooks/useSubpoena/index.ts` (1 hunks)
* `apps/judicial-system/web/src/utils/hooks/useSubpoena/subpoena.graphql` (1 hunks)

</details>

<details>
<summary>🧰 Additional context used</summary>

<details>
<summary>📓 Path-based instructions (1)</summary>

<details>
<summary>`apps/**/*`: "Confirm that the code adheres to the following:
- NextJS best practices, including file structure, API routes, and static generation methods.
- Efficient state manage...</summary>

> `apps/**/*`: "Confirm that the code adheres to the following:
> - NextJS best practices, including file structure, API routes, and static generation methods.
> - Efficient state management and server-side rendering techniques.
> - Optimal use of TypeScript for component and utility type safety."
> 

- `apps/judicial-system/web/src/utils/hooks/useSubpoena/subpoena.graphql`
- `apps/judicial-system/backend/src/app/modules/police/models/createSubpoena.response.ts`
- `apps/judicial-system/backend/src/app/modules/subpoena/internalSubpoena.controller.ts`
- `apps/judicial-system/web/src/routes/Defender/Cases/defenderCases.graphql`
- `apps/judicial-system/web/src/routes/Shared/Cases/cases.graphql`
- `apps/judicial-system/backend/src/app/modules/police/police.service.ts`
- `apps/judicial-system/backend/src/app/modules/subpoena/guards/policeSubpoenaExists.guard.ts`
- `apps/judicial-system/web/src/components/FormProvider/limitedAccessCase.graphql`
- `apps/judicial-system/backend/src/app/modules/subpoena/models/subpoena.model.ts`
- `apps/judicial-system/backend/migrations/20250422152214-update-supoena-id.js`
- `apps/judicial-system/backend/src/app/modules/subpoena/subpoena.service.ts`
- `apps/judicial-system/web/src/components/FormProvider/case.graphql`
- `apps/judicial-system/web/src/utils/hooks/useSubpoena/index.ts`
- `apps/judicial-system/api/src/app/modules/subpoena/models/subpoena.model.ts`

</details>

</details><details>
<summary>🧠 Learnings (13)</summary>

<details>
<summary>apps/judicial-system/web/src/utils/hooks/useSubpoena/subpoena.graphql (1)</summary>

```
Learnt from: gudjong
PR: island-is/island.is#16863
File: apps/judicial-system/web/src/components/FormProvider/case.graphql:47-47
Timestamp: 2024-11-27T14:33:19.485Z
Learning: In the `Case` GraphQL query at `apps/judicial-system/web/src/components/FormProvider/case.graphql`, the `defendantId` field is not needed in the `subpoenas` object within the `mergedCases.defendants` array.
```

</details>
<details>
<summary>apps/judicial-system/backend/src/app/modules/police/models/createSubpoena.response.ts (2)</summary>

```
Learnt from: oddsson
PR: island-is/island.is#16177
File: apps/judicial-system/backend/src/app/modules/subpoena/dto/updateSubpoena.dto.ts:16-16
Timestamp: 2024-10-04T15:11:19.318Z
Learning: In the TypeScript file `apps/judicial-system/xrd-api/src/app/dto/subpoena.dto.ts`, the property is `servedBy`, not `registeredBy`. It is correctly named, and no renaming is necessary.
```

```
Learnt from: unakb
PR: island-is/island.is#16393
File: apps/judicial-system/digital-mailbox-api/src/app/modules/cases/models/subpoena.response.ts:164-169
Timestamp: 2024-10-14T21:34:16.234Z
Learning: Ensure that suggested code changes in `subpoena.response.ts` are accurate and necessary, avoiding redundant suggestions.
```

</details>
<details>
<summary>apps/judicial-system/backend/src/app/modules/subpoena/internalSubpoena.controller.ts (3)</summary>

```
Learnt from: gudjong
PR: island-is/island.is#16863
File: apps/judicial-system/backend/src/app/modules/subpoena/subpoena.controller.ts:86-98
Timestamp: 2024-11-27T15:27:52.059Z
Learning: In `apps/judicial-system/backend/src/app/modules/subpoena/subpoena.controller.ts`, user action auditing and exception handling are performed at a higher level, so explicit error handling and logging within the `getSubpoena` method is unnecessary.
```

```
Learnt from: unakb
PR: island-is/island.is#16393
File: apps/judicial-system/digital-mailbox-api/src/app/modules/cases/models/subpoena.response.ts:164-169
Timestamp: 2024-10-14T21:34:16.234Z
Learning: Ensure that suggested code changes in `subpoena.response.ts` are accurate and necessary, avoiding redundant suggestions.
```

```
Learnt from: oddsson
PR: island-is/island.is#16329
File: apps/judicial-system/backend/src/app/modules/notification/subpoenaNotification.service.ts:0-0
Timestamp: 2024-10-15T10:31:27.440Z
Learning: In `apps/judicial-system/backend/src/app/modules/subpoena/subpoena.service.ts`, the method `findBySubpoenaId` throws an error if the subpoena is not found. Therefore, downstream code does not need to check if the result is undefined.
```

</details>
<details>
<summary>apps/judicial-system/web/src/routes/Defender/Cases/defenderCases.graphql (1)</summary>

```
Learnt from: gudjong
PR: island-is/island.is#16863
File: apps/judicial-system/web/src/components/FormProvider/case.graphql:47-47
Timestamp: 2024-11-27T14:33:19.485Z
Learning: In the `Case` GraphQL query at `apps/judicial-system/web/src/components/FormProvider/case.graphql`, the `defendantId` field is not needed in the `subpoenas` object within the `mergedCases.defendants` array.
```

</details>
<details>
<summary>apps/judicial-system/web/src/routes/Shared/Cases/cases.graphql (1)</summary>

```
Learnt from: gudjong
PR: island-is/island.is#16863
File: apps/judicial-system/web/src/components/FormProvider/case.graphql:47-47
Timestamp: 2024-11-27T14:33:19.485Z
Learning: In the `Case` GraphQL query at `apps/judicial-system/web/src/components/FormProvider/case.graphql`, the `defendantId` field is not needed in the `subpoenas` object within the `mergedCases.defendants` array.
```

</details>
<details>
<summary>apps/judicial-system/backend/src/app/modules/police/police.service.ts (1)</summary>

```
Learnt from: unakb
PR: island-is/island.is#16393
File: apps/judicial-system/digital-mailbox-api/src/app/modules/cases/models/subpoena.response.ts:164-169
Timestamp: 2024-10-14T21:34:16.234Z
Learning: Ensure that suggested code changes in `subpoena.response.ts` are accurate and necessary, avoiding redundant suggestions.
```

</details>
<details>
<summary>apps/judicial-system/backend/src/app/modules/subpoena/guards/policeSubpoenaExists.guard.ts (3)</summary>

```
Learnt from: gudjong
PR: island-is/island.is#16863
File: apps/judicial-system/backend/src/app/modules/subpoena/limitedAccessSubpoena.controller.ts:56-56
Timestamp: 2024-11-27T15:15:53.740Z
Learning: In `apps/judicial-system/backend/src/app/modules/subpoena/subpoena.controller.ts`, the usage of `SubpoenaExistsOptionalGuard` is correct and should not be replaced.
```

```
Learnt from: oddsson
PR: island-is/island.is#16463
File: apps/judicial-system/backend/src/app/modules/subpoena/test/limitedAccessSubpoenaController/limitedAccessSubpoenaControllerGuards.spec.ts:17-17
Timestamp: 2024-10-21T21:14:47.668Z
Learning: In `LimitedAccessSubpoenaController`, `SubpoenaExistsOptionalGuard` is still used on specific endpoints not covered by the test file `limitedAccessSubpoenaControllerGuards.spec.ts`.
```

```
Learnt from: oddsson
PR: island-is/island.is#16329
File: apps/judicial-system/backend/src/app/modules/notification/subpoenaNotification.service.ts:0-0
Timestamp: 2024-10-15T10:31:27.440Z
Learning: In `apps/judicial-system/backend/src/app/modules/subpoena/subpoena.service.ts`, the method `findBySubpoenaId` throws an error if the subpoena is not found. Therefore, downstream code does not need to check if the result is undefined.
```

</details>
<details>
<summary>apps/judicial-system/web/src/components/FormProvider/limitedAccessCase.graphql (1)</summary>

```
Learnt from: gudjong
PR: island-is/island.is#16863
File: apps/judicial-system/web/src/components/FormProvider/case.graphql:47-47
Timestamp: 2024-11-27T14:33:19.485Z
Learning: In the `Case` GraphQL query at `apps/judicial-system/web/src/components/FormProvider/case.graphql`, the `defendantId` field is not needed in the `subpoenas` object within the `mergedCases.defendants` array.
```

</details>
<details>
<summary>apps/judicial-system/backend/src/app/modules/subpoena/models/subpoena.model.ts (1)</summary>

```
Learnt from: oddsson
PR: island-is/island.is#16177
File: apps/judicial-system/backend/src/app/modules/subpoena/dto/updateSubpoena.dto.ts:16-16
Timestamp: 2024-10-04T15:11:19.318Z
Learning: In the TypeScript file `apps/judicial-system/xrd-api/src/app/dto/subpoena.dto.ts`, the property is `servedBy`, not `registeredBy`. It is correctly named, and no renaming is necessary.
```

</details>
<details>
<summary>apps/judicial-system/backend/src/app/modules/subpoena/subpoena.service.ts (2)</summary>

```
Learnt from: oddsson
PR: island-is/island.is#16329
File: apps/judicial-system/backend/src/app/modules/notification/subpoenaNotification.service.ts:0-0
Timestamp: 2024-10-15T10:31:27.440Z
Learning: In `apps/judicial-system/backend/src/app/modules/subpoena/subpoena.service.ts`, the method `findBySubpoenaId` throws an error if the subpoena is not found. Therefore, downstream code does not need to check if the result is undefined.
```

```
Learnt from: oddsson
PR: island-is/island.is#16177
File: apps/judicial-system/backend/src/app/modules/subpoena/dto/updateSubpoena.dto.ts:16-16
Timestamp: 2024-10-04T15:11:19.318Z
Learning: In the TypeScript file `apps/judicial-system/xrd-api/src/app/dto/subpoena.dto.ts`, the property is `servedBy`, not `registeredBy`. It is correctly named, and no renaming is necessary.
```

</details>
<details>
<summary>apps/judicial-system/web/src/components/FormProvider/case.graphql (1)</summary>

```
Learnt from: gudjong
PR: island-is/island.is#16863
File: apps/judicial-system/web/src/components/FormProvider/case.graphql:47-47
Timestamp: 2024-11-27T14:33:19.485Z
Learning: In the `Case` GraphQL query at `apps/judicial-system/web/src/components/FormProvider/case.graphql`, the `defendantId` field is not needed in the `subpoenas` object within the `mergedCases.defendants` array.
```

</details>
<details>
<summary>apps/judicial-system/web/src/utils/hooks/useSubpoena/index.ts (2)</summary>

```
Learnt from: unakb
PR: island-is/island.is#16393
File: apps/judicial-system/digital-mailbox-api/src/app/modules/cases/models/subpoena.response.ts:164-169
Timestamp: 2024-10-14T21:34:16.234Z
Learning: Ensure that suggested code changes in `subpoena.response.ts` are accurate and necessary, avoiding redundant suggestions.
```

```
Learnt from: oddsson
PR: island-is/island.is#16329
File: apps/judicial-system/backend/src/app/modules/notification/subpoenaNotification.service.ts:0-0
Timestamp: 2024-10-15T10:31:27.440Z
Learning: In `apps/judicial-system/backend/src/app/modules/subpoena/subpoena.service.ts`, the method `findBySubpoenaId` throws an error if the subpoena is not found. Therefore, downstream code does not need to check if the result is undefined.
```

</details>
<details>
<summary>apps/judicial-system/api/src/app/modules/subpoena/models/subpoena.model.ts (1)</summary>

```
Learnt from: oddsson
PR: island-is/island.is#16177
File: apps/judicial-system/backend/src/app/modules/subpoena/dto/updateSubpoena.dto.ts:16-16
Timestamp: 2024-10-04T15:11:19.318Z
Learning: In the TypeScript file `apps/judicial-system/xrd-api/src/app/dto/subpoena.dto.ts`, the property is `servedBy`, not `registeredBy`. It is correctly named, and no renaming is necessary.
```

</details>

</details><details>
<summary>🪛 Biome (1.9.4)</summary>

<details>
<summary>apps/judicial-system/backend/migrations/20250422152214-update-supoena-id.js</summary>

[error] 1-1: Redundant use strict directive.

The entire contents of JavaScript modules are automatically in strict mode, with no statement needed to initiate it.
Safe fix: Remove the redundant use strict directive.


(lint/suspicious/noRedundantUseStrict)

</details>

</details>

</details>

<details>
<summary>🔇 Additional comments (23)</summary><blockquote>

<details>
<summary>apps/judicial-system/web/src/routes/Defender/Cases/defenderCases.graphql (1)</summary>

`29-29`: **Correctly renamed field from subpoenaId to policeSubpoenaId**

The field rename is consistent with the PR objective to make a clear distinction between `subpoenaId` and `subpoena.id`. This change helps prevent confusion and potential bugs by using more specific naming.

</details>
<details>
<summary>apps/judicial-system/backend/src/app/modules/police/models/createSubpoena.response.ts (1)</summary>

`5-5`: **API response property successfully renamed**

The property in the `CreateSubpoenaResponse` class has been correctly renamed from `subpoenaId` to `policeSubpoenaId`. This change affects the API response shape, which is consistent with the PR objective to standardize terminology across the application.

</details>
<details>
<summary>apps/judicial-system/web/src/utils/hooks/useSubpoena/subpoena.graphql (1)</summary>

`12-12`: **GraphQL query field appropriately renamed**

The field has been successfully renamed from `subpoenaId` to `policeSubpoenaId` in the Subpoena GraphQL query. This change aligns with NextJS and TypeScript best practices by ensuring consistency in field naming across the frontend and backend.

</details>
<details>
<summary>apps/judicial-system/backend/src/app/modules/subpoena/guards/policeSubpoenaExists.guard.ts (1)</summary>

`24-26`: **Service method call updated to match renamed method**

The guard has been updated to call `findByPoliceSubpoenaId()` instead of `findBySubpoenaId()`, which correctly aligns with the service method renaming. This ensures consistent terminology throughout the codebase and maintains the guard's functionality.

</details>
<details>
<summary>apps/judicial-system/backend/src/app/modules/subpoena/models/subpoena.model.ts (1)</summary>

`57-57`: **Field renamed correctly to improve clarity.**

The property has been renamed from `subpoenaId` to `policeSubpoenaId` which aligns with the PR objectives of distinguishing this field from `subpoena.id`. This rename will help prevent confusion and potential bugs from mixing these identifiers.

</details>
<details>
<summary>apps/judicial-system/web/src/routes/Shared/Cases/cases.graphql (1)</summary>

`37-37`: **Field renamed correctly in GraphQL query.**

The `policeSubpoenaId` field name is now being used consistently in the GraphQL query, matching the backend model changes. This ensures data fetching remains intact across the application.

</details>
<details>
<summary>apps/judicial-system/web/src/components/FormProvider/limitedAccessCase.graphql (1)</summary>

`65-65`: **Field renamed correctly in limitedAccessCase GraphQL query.**

The `policeSubpoenaId` field name is now being used consistently in this query, matching the backend model changes and other GraphQL queries. This consistency across the codebase ensures proper data handling.

</details>
<details>
<summary>apps/judicial-system/api/src/app/modules/subpoena/models/subpoena.model.ts (1)</summary>

`19-19`: **Field renamed correctly in GraphQL model.**

The property has been renamed from `subpoenaId` to `policeSubpoenaId` in the GraphQL model while preserving its nullable String type definition. This change properly aligns the API layer with the backend model changes and ensures consistent naming across the stack.

</details>
<details>
<summary>apps/judicial-system/backend/src/app/modules/subpoena/internalSubpoena.controller.ts (1)</summary>

`99-99`: **Properly renamed property to policeSubpoenaId**

This change correctly renames the property accessed on the `currentSubpoena` object from `subpoenaId` to `policeSubpoenaId` in the audit logging callback function. This aligns with the PR objective to avoid confusion between `subpoenaId` and `subpoena.id`.

</details>
<details>
<summary>apps/judicial-system/web/src/utils/hooks/useSubpoena/index.ts (1)</summary>

`10-11`: **Updated skip condition to check for policeSubpoenaId**

The condition for skipping the GraphQL query has been properly updated to check for the existence of `policeSubpoenaId` instead of `subpoenaId`. This change correctly implements the renaming pattern consistent with the rest of the codebase.


This change maintains TypeScript type safety while ensuring the hook's behavior remains the same, adhering to NextJS best practices for efficient component state management.

</details>
<details>
<summary>apps/judicial-system/web/src/components/FormProvider/case.graphql (2)</summary>

`53-53`: **Renamed GraphQL field to policeSubpoenaId in defendants.subpoenas**

The GraphQL query has been updated to request `policeSubpoenaId` instead of `subpoenaId`, ensuring the frontend aligns with the backend model changes.

---

`372-372`: **Renamed GraphQL field to policeSubpoenaId in mergedCases.defendants.subpoenas**

The field has been appropriately renamed in the nested structure for merged cases, maintaining consistency throughout the query.

</details>
<details>
<summary>apps/judicial-system/backend/src/app/modules/police/police.service.ts (1)</summary>

`666-666`: **Updated response property name to policeSubpoenaId**

The property name in the return object of the `createSubpoena` method has been properly updated from `subpoenaId` to `policeSubpoenaId`. This ensures consistency with the renamed field in the `CreateSubpoenaResponse` model and the broader renaming effort across the codebase.

</details>
<details>
<summary>apps/judicial-system/backend/migrations/20250422152214-update-supoena-id.js (2)</summary>

`4-17`: **Migration correctly renames the column in a transaction**

The migration properly uses a transaction to rename the database column from `subpoena_id` to `police_subpoena_id`, ensuring atomicity of the change.

---

`19-32`: **Down migration correctly handles reverting the column name**

The down migration properly reverses the change by renaming the column back to `subpoena_id` if needed, also wrapped in a transaction for safety.

</details>
<details>
<summary>apps/judicial-system/backend/src/app/modules/subpoena/subpoena.service.ts (8)</summary>

`289-302`: **Method renamed for clarity and consistency**

The method has been correctly renamed from `findBySubpoenaId` to `findByPoliceSubpoenaId` to align with the PR objective of renaming the field to prevent confusion between `subpoenaId` and `subpoena.id`. The error message has also been updated appropriately.

Based on the retrieved learnings, this method throws an error if the subpoena is not found, which is maintained in this update.

---

`356-357`: **Field reference updated consistently**

The field reference in the update operation has been correctly changed from `subpoenaId` to `policeSubpoenaId`.

---

`367-368`: **Log message updated to reflect new field name**

The log message has been updated to reference `policeSubpoenaId` instead of `subpoenaId`, maintaining consistency in terminology throughout the codebase.

---

`489-494`: **Condition check updated for new field name**

The check for the existence of the subpoena ID has been updated to use `policeSubpoenaId` instead of `subpoenaId`.

---

`497-500`: **Method parameter updated for consistency**

The call to the police service's `revokeSubpoena` method now correctly uses `policeSubpoenaId`.

---

`504-505`: **Log message updated for new field name**

The log message formatting has been updated to reference `policeSubpoenaId` instead of `subpoenaId`, maintaining consistent terminology.

---

`513-516`: **Condition check updated for renamed field**

The check for the existence of the subpoena ID has been updated to use `policeSubpoenaId` instead of `subpoenaId`.

---

`526-528`: **Service call updated to use renamed field**

The call to `getSubpoenaStatus` now correctly passes the `policeSubpoenaId` instead of `subpoenaId`.

</details>

</blockquote></details>

</details>

<!-- This is an auto-generated comment by CodeRabbit for review status -->
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-04-22T16:01:16Z
user: login: coderabbitai[bot]
state: APPROVED
author_association: CONTRIBUTOR
submitted_at: 2025-04-22T16:01:19Z
user: login: oddsson
state: COMMENTED
author_association: MEMBER
submitted_at: 2025-04-22T20:43:52Z
user: login: oddsson
state: COMMENTED
author_association: MEMBER
submitted_at: 2025-04-22T20:44:26Z
user: login: oddsson
state: APPROVED
author_association: MEMBER
submitted_at: 2025-04-22T20:45:13Z
user: login: thorhildurt
state: COMMENTED
author_association: MEMBER
submitted_at: 2025-04-23T10:02:56Z
user: login: oddsson
state: APPROVED
author_association: MEMBER
submitted_at: 2025-04-23T10:58:49Z
user: login: thorhildurt
state: COMMENTED
author_association: MEMBER
submitted_at: 2025-04-23T10:59:49Z
user: login: coderabbitai[bot]
body: **Actionable comments posted: 0**

<details>
<summary>🧹 Nitpick comments (1)</summary><blockquote>

<details>
<summary>apps/judicial-system/xrd-api/src/app/app.service.ts (1)</summary><blockquote>

`168-171`: **Consider removing or clarifying the TODO comment.**

The TODO comment seems to be describing the current state rather than indicating future work. Consider removing it or clarifying what action is needed.

```diff
-      // TODO: this is now police subpoena id
+      // Using policeSubpoenaId in API call
```

The URL path in the fetch call has been correctly updated to use `policeSubpoenaId`.

</blockquote></details>

</blockquote></details>

<details>
<summary>📜 Review details</summary>

**Configuration used: .coderabbit.yaml**
**Review profile: CHILL**
**Plan: Pro**

<details>
<summary>📥 Commits</summary>

Reviewing files that changed from the base of the PR and between 04b650bd0a44e232855f174f5f1109a886fe0c58 and fd50e489936d7e73cf9783fdcb9261bca0e85aff.

</details>

<details>
<summary>📒 Files selected for processing (8)</summary>

* `apps/judicial-system/backend/src/app/modules/police/police.service.ts` (8 hunks)
* `apps/judicial-system/backend/src/app/modules/subpoena/guards/policeSubpoenaExists.guard.ts` (1 hunks)
* `apps/judicial-system/backend/src/app/modules/subpoena/guards/test/policeSubpoenaExistsGuard.spec.ts` (3 hunks)
* `apps/judicial-system/backend/src/app/modules/subpoena/internalSubpoena.controller.ts` (2 hunks)
* `apps/judicial-system/backend/src/app/modules/subpoena/subpoena.service.ts` (7 hunks)
* `apps/judicial-system/backend/src/app/modules/subpoena/test/internalSubpoenaController/deliverSubpoenaRevocationToPolice.spec.ts` (1 hunks)
* `apps/judicial-system/xrd-api/src/app/app.controller.ts` (1 hunks)
* `apps/judicial-system/xrd-api/src/app/app.service.ts` (2 hunks)

</details>

<details>
<summary>🚧 Files skipped from review as they are similar to previous changes (4)</summary>

* apps/judicial-system/backend/src/app/modules/subpoena/guards/policeSubpoenaExists.guard.ts
* apps/judicial-system/backend/src/app/modules/subpoena/internalSubpoena.controller.ts
* apps/judicial-system/backend/src/app/modules/subpoena/subpoena.service.ts
* apps/judicial-system/backend/src/app/modules/police/police.service.ts

</details>

<details>
<summary>🧰 Additional context used</summary>

<details>
<summary>📓 Path-based instructions (1)</summary>

<details>
<summary>`apps/**/*`: "Confirm that the code adheres to the following:
- NextJS best practices, including file structure, API routes, and static generation methods.
- Efficient state manage...</summary>

> `apps/**/*`: "Confirm that the code adheres to the following:
> - NextJS best practices, including file structure, API routes, and static generation methods.
> - Efficient state management and server-side rendering techniques.
> - Optimal use of TypeScript for component and utility type safety."
> 

- `apps/judicial-system/backend/src/app/modules/subpoena/test/internalSubpoenaController/deliverSubpoenaRevocationToPolice.spec.ts`
- `apps/judicial-system/xrd-api/src/app/app.service.ts`
- `apps/judicial-system/backend/src/app/modules/subpoena/guards/test/policeSubpoenaExistsGuard.spec.ts`
- `apps/judicial-system/xrd-api/src/app/app.controller.ts`

</details>

</details><details>
<summary>🧠 Learnings (4)</summary>

<details>
<summary>apps/judicial-system/backend/src/app/modules/subpoena/test/internalSubpoenaController/deliverSubpoenaRevocationToPolice.spec.ts (2)</summary>

```
Learnt from: unakb
PR: island-is/island.is#16393
File: apps/judicial-system/digital-mailbox-api/src/app/modules/cases/models/subpoena.response.ts:164-169
Timestamp: 2024-10-14T21:34:16.234Z
Learning: Ensure that suggested code changes in `subpoena.response.ts` are accurate and necessary, avoiding redundant suggestions.
```

```
Learnt from: unakb
PR: island-is/island.is#16863
File: apps/judicial-system/api/src/app/modules/subpoena/subpoena.resolver.ts:38-40
Timestamp: 2024-11-27T10:45:48.795Z
Learning: In the `SubpoenaResolver` class in `apps/judicial-system/api/src/app/modules/subpoena/subpoena.resolver.ts`, logging UUIDs such as `subpoenaId`, `defendantId`, and `caseId` is acceptable, as they are not considered sensitive in this context.
```

</details>
<details>
<summary>apps/judicial-system/xrd-api/src/app/app.service.ts (1)</summary>

```
Learnt from: oddsson
PR: island-is/island.is#16177
File: apps/judicial-system/backend/src/app/modules/subpoena/dto/updateSubpoena.dto.ts:16-16
Timestamp: 2024-10-04T15:11:19.318Z
Learning: In the TypeScript file `apps/judicial-system/xrd-api/src/app/dto/subpoena.dto.ts`, the property is `servedBy`, not `registeredBy`. It is correctly named, and no renaming is necessary.
```

</details>
<details>
<summary>apps/judicial-system/backend/src/app/modules/subpoena/guards/test/policeSubpoenaExistsGuard.spec.ts (2)</summary>

```
Learnt from: oddsson
PR: island-is/island.is#16463
File: apps/judicial-system/backend/src/app/modules/subpoena/test/limitedAccessSubpoenaController/limitedAccessSubpoenaControllerGuards.spec.ts:17-17
Timestamp: 2024-10-21T21:14:47.668Z
Learning: In `LimitedAccessSubpoenaController`, `SubpoenaExistsOptionalGuard` is still used on specific endpoints not covered by the test file `limitedAccessSubpoenaControllerGuards.spec.ts`.
```

```
Learnt from: gudjong
PR: island-is/island.is#16863
File: apps/judicial-system/backend/src/app/modules/subpoena/limitedAccessSubpoena.controller.ts:56-56
Timestamp: 2024-11-27T15:15:53.740Z
Learning: In `apps/judicial-system/backend/src/app/modules/subpoena/subpoena.controller.ts`, the usage of `SubpoenaExistsOptionalGuard` is correct and should not be replaced.
```

</details>
<details>
<summary>apps/judicial-system/xrd-api/src/app/app.controller.ts (1)</summary>

```
Learnt from: oddsson
PR: island-is/island.is#16177
File: apps/judicial-system/backend/src/app/modules/subpoena/dto/updateSubpoena.dto.ts:16-16
Timestamp: 2024-10-04T15:11:19.318Z
Learning: In the TypeScript file `apps/judicial-system/xrd-api/src/app/dto/subpoena.dto.ts`, the property is `servedBy`, not `registeredBy`. It is correctly named, and no renaming is necessary.
```

</details>

</details>

</details>

<details>
<summary>🔇 Additional comments (12)</summary><blockquote>

<details>
<summary>apps/judicial-system/backend/src/app/modules/subpoena/test/internalSubpoenaController/deliverSubpoenaRevocationToPolice.spec.ts (1)</summary>

`23-23`: **LGTM! Field renamed to match PR objective.**

The change correctly implements the renaming from `subpoenaId` to `policeSubpoenaId` in the subpoena object. This ensures consistency with the changes in the rest of the codebase and helps avoid confusion between `subpoena.id` and the police-specific identifier.

</details>
<details>
<summary>apps/judicial-system/backend/src/app/modules/subpoena/guards/test/policeSubpoenaExistsGuard.spec.ts (4)</summary>

`51-51`: **LGTM! Field renamed to match PR objective.**

The change correctly updates the test data to use `policeSubpoenaId` instead of `subpoenaId` in the subpoena mock object.

---

`53-53`: **LGTM! Parameter renamed consistently.**

The request params now use `policeSubpoenaId` which correctly aligns with the renamed field in the guard implementation.

---

`69-69`: **LGTM! Query condition updated correctly.**

The where clause in the database query has been properly updated to use `policeSubpoenaId`.

---

`82-82`: **LGTM! Parameter renamed consistently.**

The request params are correctly updated to use `policeSubpoenaId` in this test case as well.

</details>
<details>
<summary>apps/judicial-system/xrd-api/src/app/app.controller.ts (4)</summary>

`74-75`: **LGTM! Route and comment updated correctly.**

The endpoint route and associated comment have been properly updated to use `policeSubpoenaId` instead of `subpoenaId`.

---

`79-79`: **LGTM! Method parameter renamed consistently.**

The parameter has been correctly updated from `subpoenaId` to `policeSubpoenaId` in the controller method signature.

---

`82-82`: **LGTM! Log message updated correctly.**

The logging statement has been updated to refer to the subpoena using the renamed `policeSubpoenaId`.

---

`84-84`: **LGTM! Service method call updated correctly.**

The service method call has been updated to use the renamed `policeSubpoenaId` parameter.

</details>
<details>
<summary>apps/judicial-system/xrd-api/src/app/app.service.ts (3)</summary>

`84-85`: **LGTM! Method parameter renamed consistently.**

The parameter in the `updateSubpoena` method has been correctly updated from `subpoenaId` to `policeSubpoenaId`.

---

`90-92`: **LGTM! Method call and audit information updated correctly.**

Both the method call and the audit information now use `policeSubpoenaId` consistently.

---

`96-97`: **LGTM! Private method parameter renamed consistently.**

The parameter in the private `updateSubpoenaInfo` method has been correctly updated from `subpoenaId` to `policeSubpoenaId`.

</details>

</blockquote></details>

</details>

<!-- This is an auto-generated comment by CodeRabbit for review status -->
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-04-23T11:01:36Z

Review comments:
diff_hunk: @@ -21,7 +21,9 @@ export class PoliceSubpoenaExistsGuard implements CanActivate {
     }
 
     // subpoenaId is the external police document id
-    request.subpoena = await this.subpoenaService.findBySubpoenaId(subpoenaId)
+    request.subpoena = await this.subpoenaService.findByPoliceSubpoenaId(
+      subpoenaId,
path: apps/judicial-system/backend/src/app/modules/subpoena/guards/policeSubpoenaExists.guard.ts
user: login: oddsson
body: Should we maybe rename this as well to `policeSubpoenaId`?
created_at: 2025-04-22T20:43:51Z
author_association: MEMBER
diff_hunk: @@ -286,10 +286,10 @@ export class SubpoenaService {
     return subpoena
   }
 
-  async findBySubpoenaId(policeSubpoenaId?: string): Promise<Subpoena> {
+  async findByPoliceSubpoenaId(policeSubpoenaId?: string): Promise<Subpoena> {
     const subpoena = await this.subpoenaModel.findOne({
       include,
-      where: { subpoenaId: policeSubpoenaId },
+      where: { policeSubpoenaId: policeSubpoenaId },
path: apps/judicial-system/backend/src/app/modules/subpoena/subpoena.service.ts
user: login: oddsson
body: ```suggestion
      where: { policeSubpoenaId },
```
created_at: 2025-04-22T20:44:26Z
author_association: MEMBER
diff_hunk: @@ -21,7 +21,9 @@ export class PoliceSubpoenaExistsGuard implements CanActivate {
     }
 
     // subpoenaId is the external police document id
-    request.subpoena = await this.subpoenaService.findBySubpoenaId(subpoenaId)
+    request.subpoena = await this.subpoenaService.findByPoliceSubpoenaId(
+      subpoenaId,
path: apps/judicial-system/backend/src/app/modules/subpoena/guards/policeSubpoenaExists.guard.ts
user: login: thorhildurt
body: Yes 🙌  and from this I spotted several other params that should be renamed as well
created_at: 2025-04-23T10:02:56Z
author_association: MEMBER
diff_hunk: @@ -71,15 +71,16 @@ export class AppController {
     }
   }
 
-  @Patch('subpoena/:subpoenaId')
+  // update by police subpoena id
+  @Patch('subpoena/:policeSubpoenaId')
path: apps/judicial-system/xrd-api/src/app/app.controller.ts
user: login: thorhildurt
body: We need to ensure to regression test this on dev due to the rename. This should not be a breaking change for external users? since they just concat the id in the url, right?
created_at: 2025-04-23T10:59:49Z
author_association: MEMBER

PR comments:
user: login: coderabbitai[bot]
created_at: 2025-04-22T15:51:53Z
body: <!-- This is an auto-generated comment: summarize by coderabbit.ai -->
<!-- walkthrough_start -->

## Walkthrough

This change set systematically renames the identifier field for police subpoenas from `subpoenaId` to `policeSubpoenaId` across the codebase. The update includes model definitions, GraphQL queries, service methods, migration scripts, and guards to ensure consistent naming. The migration script renames the relevant database column, while all API, backend, and frontend references are updated to use the new field name. No changes to control flow or additional logic are introduced; the modifications are limited to naming and field access for clarity and consistency.

## Changes

| Files/Paths                                                                                                                                                  | Change Summary                                                                                                      |
|--------------------------------------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------|
| .../api/src/app/modules/subpoena/models/subpoena.model.ts<br>.../backend/src/app/modules/subpoena/models/subpoena.model.ts                                  | Renamed the `subpoenaId` property to `policeSubpoenaId` in the `Subpoena` model (API and backend).                 |
| .../backend/src/app/modules/police/models/createSubpoena.response.ts                                                                                        | Renamed `subpoenaId` to `policeSubpoenaId` in the `CreateSubpoenaResponse` class.                                  |
| .../backend/src/app/modules/police/police.service.ts                                                                                                        | Renamed method parameters and references from `subpoenaId` to `policeSubpoenaId` in `getSubpoenaStatus`, `createSubpoena`, and `revokeSubpoena`. Changed return object key in `createSubpoena`. Updated URL query params, error messages, logs, and event payloads accordingly. |
| .../backend/src/app/modules/subpoena/guards/policeSubpoenaExists.guard.ts                                                                                   | Updated guard to extract and validate `policeSubpoenaId` from request params and call `findByPoliceSubpoenaId` method. |
| .../backend/src/app/modules/subpoena/internalSubpoena.controller.ts                                                                                        | Changed route parameter and method argument from `subpoenaId` to `policeSubpoenaId`. Updated debug logs and audit log details to use `policeSubpoenaId`. |
| .../backend/src/app/modules/subpoena/subpoena.service.ts                                                                                                   | Renamed method `findBySubpoenaId` to `findByPoliceSubpoenaId`, updated query conditions and all references to use `policeSubpoenaId`. Updated logging and conditional checks in multiple methods accordingly. |
| .../backend/migrations/20250422152214-update-supoena-id.js                                                                                                | Added migration script to rename the `subpoena_id` column to `police_subpoena_id` in the `subpoena` table, with transactional safety. |
| .../web/src/components/FormProvider/case.graphql<br>.../web/src/components/FormProvider/limitedAccessCase.graphql<br>.../web/src/routes/Defender/Cases/defenderCases.graphql<br>.../web/src/routes/Shared/Cases/cases.graphql<br>.../web/src/utils/hooks/useSubpoena/subpoena.graphql | Renamed GraphQL field `subpoenaId` to `policeSubpoenaId` in all relevant queries and nested selections.            |
| .../web/src/utils/hooks/useSubpoena/index.ts                                                                                                              | Changed conditional logic to check for `policeSubpoenaId` instead of `subpoenaId` before executing the subpoena query. |
| .../backend/src/app/modules/subpoena/guards/test/policeSubpoenaExistsGuard.spec.ts                                                                         | Updated test cases to use `policeSubpoenaId` instead of `subpoenaId` in mock data, request params, and query expectations. |
| .../backend/src/app/modules/subpoena/test/internalSubpoenaController/deliverSubpoenaRevocationToPolice.spec.ts                                             | Updated test data property from `subpoenaId` to `policeSubpoenaId` to align with controller logic.                  |
| .../xrd-api/src/app/app.controller.ts                                                                                                                     | Changed PATCH endpoint route parameter and method argument from `subpoenaId` to `policeSubpoenaId`. Updated logging and service call accordingly. |
| .../xrd-api/src/app/app.service.ts                                                                                                                        | Renamed method parameters and internal references from `subpoenaId` to `policeSubpoenaId` in `updateSubpoena` and `updateSubpoenaInfo` methods. Updated URL in fetch call and added clarifying comment. |

## Sequence Diagram(s)

```mermaid
sequenceDiagram
  participant Frontend
  participant GraphQL API
  participant Backend Service
  participant Database

  Frontend->>GraphQL API: Query/Mutation with policeSubpoenaId
  GraphQL API->>Backend Service: Call with policeSubpoenaId
  Backend Service->>Database: Query/Update using policeSubpoenaId
  Database-->>Backend Service: Result
  Backend Service-->>GraphQL API: Response with policeSubpoenaId
  GraphQL API-->>Frontend: Response with policeSubpoenaId
```

## Suggested labels

`deprecated:automerge`

<!-- walkthrough_end -->


---

<details>
<summary>📜 Recent review details</summary>

**Configuration used: .coderabbit.yaml**
**Review profile: CHILL**
**Plan: Pro**

<details>
<summary>📥 Commits</summary>

Reviewing files that changed from the base of the PR and between fd50e489936d7e73cf9783fdcb9261bca0e85aff and d68f8f3b8da7d5c9534d3f6dc5369279ef10fe27.

</details>

<details>
<summary>📒 Files selected for processing (1)</summary>

* `apps/judicial-system/xrd-api/src/app/app.service.ts` (2 hunks)

</details>

<details>
<summary>🚧 Files skipped from review as they are similar to previous changes (1)</summary>

* apps/judicial-system/xrd-api/src/app/app.service.ts

</details>

</details>
<!-- internal state start -->


<!-- DwQgtGAEAqAWCWBnSTIEMB26CuAXA9mAOYCmGJATmriQCaQDG+Ats2bgFyQAOFk+AIwBWJBrngA3EsgEBPRvlqU0AgfFwA6NPEgQAfACgjoCEYDEZyAAUASpETZWaCrKNxU3bABsvkCiQBHbGlcABpIcVwvOkgAIgAzeAAPAAohMEQASi5/DDQ2e2wBbnwyNABJegIefC94BhIAZSKSssrQ2MgAdzRkBwFmdRp6OQjYEkhsREox/AoEL1psClx0DHpUeCUMcUSY3sgMRwEZgEYADnOAZgA2FCxccb8SEsR1OdkNGCfmbSwGWCYUj3CS1KTIXL5eAYIhjCYSZzwFTRSAAA36rTylVREXwaJKdQazWKpSxtBxjwo+GwRFg1NWjwmTCUAl6JC+cAmngorwm+HiY1QkMGMJQyGqaFBWwUGHiU3g+CwJ1wXRIZDRGNJFXJa3o6JaWo0W1R4S6CABkEB9F4JAkCqmXnkDDQU32kAENMgSwm1UGSWhsMZ0xQ2128EoiA0bieSkQDAo8G44kVkBISW4Xj+4sB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soGROXIUSqJKhRhrRM0JmYb0JDKSRnjhl5A0SzUmwjDOwK4y0ACMkiVqEsnWSiG6MmDPZMupeFnJnDTXpxICLcTvJnoqKUJN3RQ1JGgMoQj+NEJLlNYKCXgKVJoDoAyGJM4NGhChmEzDqd9RGfzDJmySKZyMggjZLokYyGJTeBcAmAGJnxJZFUoOPXnxmciSw+kkmcrOPp5BKZKMmibZK1l0zPCCGVEIzK4YeSwpbMiKRzIEk+juZsUw/BuxxgAx4xQVPAJdFRHQwWAXaOGAjHs4oxmQaMH6JjH+jHQFArAdQLMkQAjJvIBEOgNMkOwrAsYwctOU4gEA3AHEAgWgNYjQCOJHEJASxFcEsTnA7EdieIKcAADsjieIG3NOCnBrEAATjQCXAbgSkaxAwDsTnBi5BgEOfEFoAOISAjic4APIHm3BaAHckgB3KuAMB4gA8judcDnkMABAA8yxDcFOACBnQ1iEgC3KmYChU5EAL0DcHODxBn5VwAQOcFIgdz55DAAeXYiuCOJaAVweIDcFoATzbgJ8juQPOcj9ylIliDudPJnlpzbomcrYNnNzmqhaAIyU6MXKAA== -->

<!-- internal state end -->
<!-- tips_start -->

---

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

<details>
<summary>❤️ Share</summary>

- [X](https://twitter.com/intent/tweet?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A&url=https%3A//coderabbit.ai)
- [Mastodon](https://mastodon.social/share?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A%20https%3A%2F%2Fcoderabbit.ai)
- [Reddit](https://www.reddit.com/submit?title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&text=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code.%20Check%20it%20out%3A%20https%3A//coderabbit.ai)
- [LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fcoderabbit.ai&mini=true&title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&summary=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code)

</details>

<details>
<summary>🪧 Tips</summary>

### Chat

There are 3 ways to chat with [CodeRabbit](https://coderabbit.ai?utm_source=oss&utm_medium=github&utm_campaign=island-is/island.is&utm_content=18836):

- Review comments: Directly reply to a review comment made by CodeRabbit. Example:
  - `I pushed a fix in commit <commit_id>, please review it.`
  - `Generate unit testing code for this file.`
  - `Open a follow-up GitHub issue for this discussion.`
- Files and specific lines of code (under the "Files changed" tab): Tag `@coderabbitai` in a new review comment at the desired location with your query. Examples:
  - `@coderabbitai generate unit testing code for this file.`
  -	`@coderabbitai modularize this function.`
- PR comments: Tag `@coderabbitai` in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
  - `@coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.`
  - `@coderabbitai read src/utils.ts and generate unit testing code.`
  - `@coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.`
  - `@coderabbitai help me debug CodeRabbit configuration file.`

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

### CodeRabbit Commands (Invoked using PR comments)

- `@coderabbitai pause` to pause the reviews on a PR.
- `@coderabbitai resume` to resume the paused reviews.
- `@coderabbitai review` to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
- `@coderabbitai full review` to do a full review from scratch and review all the files again.
- `@coderabbitai summary` to regenerate the summary of the PR.
- `@coderabbitai generate docstrings` to [generate docstrings](https://docs.coderabbit.ai/finishing-touches/docstrings) for this PR.
- `@coderabbitai generate sequence diagram` to generate a sequence diagram of the changes in this PR.
- `@coderabbitai resolve` resolve all the CodeRabbit review comments.
- `@coderabbitai configuration` to show the current CodeRabbit configuration for the repository.
- `@coderabbitai help` to get help.

### Other keywords and placeholders

- Add `@coderabbitai ignore` anywhere in the PR description to prevent this PR from being reviewed.
- Add `@coderabbitai summary` to generate the high-level summary at a specific location in the PR description.
- Add `@coderabbitai` anywhere in the PR title to generate the title automatically.

### Documentation and Community

- Visit our [Documentation](https://docs.coderabbit.ai) for detailed information on how to use CodeRabbit.
- Join our [Discord Community](http://discord.gg/coderabbit) to get help, request features, and share feedback.
- Follow us on [X/Twitter](https://twitter.com/coderabbitai) for updates and announcements.

</details>

<!-- tips_end -->
author_association: CONTRIBUTOR
user: login: nx-cloud[bot]
created_at: 2025-04-22T15:55:35Z
body: 
View your [CI Pipeline Execution ↗](https://cloud.nx.app/cipes/6808ca489b99bb2f291e3387?utm_source=pull-request&utm_medium=comment) for commit d68f8f3b8da7d5c9534d3f6dc5369279ef10fe27.

| Command | Status | Duration | Result |
|---------|--------|----------:|--------|
| `nx run-many --projects judicial-system-backend ...` | ✅ Succeeded | 16m 39s | [View ↗](https://cloud.nx.app/runs/g2KEfUa53y?utm_source=pull-request&utm_medium=comment) |
| `nx run-many --target=build --projects=judicial-...` | ✅ Succeeded | 6m 21s | [View ↗](https://cloud.nx.app/runs/CIeTfrrBae?utm_source=pull-request&utm_medium=comment) |
| `nx run-many --projects judicial-system-api,judi...` | ✅ Succeeded | 3m 14s | [View ↗](https://cloud.nx.app/runs/sUsoQIhuVC?utm_source=pull-request&utm_medium=comment) |
| `nx run-many -t lint --output-style=static --pro...` | ✅ Succeeded | 2s | [View ↗](https://cloud.nx.app/runs/IrG2w07bD7?utm_source=pull-request&utm_medium=comment) |
| `nx run-many --target=codegen/frontend-client --...` | ✅ Succeeded | 13s | [View ↗](https://cloud.nx.app/runs/ZGUsL6uWLX?utm_source=pull-request&utm_medium=comment) |
| `nx run-many --target=build --projects=judicial-...` | ✅ Succeeded | 27s | [View ↗](https://cloud.nx.app/runs/iIaXm04Dfl?utm_source=pull-request&utm_medium=comment) |
| `nx run-many --target=codegen/backend-schema --a...` | ✅ Succeeded | 25s | [View ↗](https://cloud.nx.app/runs/Y7Ba1ZbFCV?utm_source=pull-request&utm_medium=comment) |
| `nx run-many --target=codegen/backend-client --a...` | ✅ Succeeded | 22s | [View ↗](https://cloud.nx.app/runs/1rsTVWVXaU?utm_source=pull-request&utm_medium=comment) |
| `Additional runs (1)` | ✅ Succeeded | ... | [View ↗](https://cloud.nx.app/cipes/6808ca489b99bb2f291e3387?utm_source=pull-request&utm_medium=comment) |

---

☁️ [Nx Cloud](https://cloud.nx.app?utm_source=pull-request&utm_medium=comment) last updated this comment at `2025-04-23 11:31:24` UTC

<!-- NX_CLOUD_APP_COMMENT_END -->
author_association: NONE
user: login: datadog-island-is[bot]
created_at: 2025-04-22T16:17:18Z
body: 
# Datadog Report

All test runs `1b26962` [:link:](https://app.datadoghq.eu/ci/test-runs?query=%40git.repository.id_v2%3A%22github.com%2Fisland-is%2Fisland.is%22+%40git.commit.sha%3A1b269621afed06ea76acc8819a9456a19b950bd8+%40git.branch%3A%22j-s%2Frename-subpoena-id%22&_user_click_origin_=github)

:white_check_mark: **4 Total Test Services**: 0 Failed, 4 Passed



<details>
<summary>Test Services</summary>

| Service Name | Failed | Known Flaky | New Flaky | Passed | Skipped | Total Time | Test Service View |
| ------------ | ------ | ----------- | --------- | ------ | ------- | --------- | ----------------- |
| [**`judicial-system-api`**](https://app.datadoghq.eu/ci/test-commit/github.com%2Fisland-is%2Fisland.is/judicial-system-api/j-s%2Frename-subpoena-id/1b269621afed06ea76acc8819a9456a19b950bd8?env=ci&index=citest&_user_click_origin_=github) | 0 | 0 | 0 | 61 | 0 | 14.81s |  [Link](https://app.datadoghq.eu/ci/test-branch/github.com%2Fisland-is%2Fisland.is/judicial-system-api/j-s%2Frename-subpoena-id?env=ci&index=citest&_user_click_origin_=github) |
| [**`judicial-system-backend`**](https://app.datadoghq.eu/ci/test-commit/github.com%2Fisland-is%2Fisland.is/judicial-system-backend/j-s%2Frename-subpoena-id/1b269621afed06ea76acc8819a9456a19b950bd8?env=ci&index=citest&_user_click_origin_=github) | 0 | 0 | 0 | 22353 | 0 | 16m 35.19s |  [Link](https://app.datadoghq.eu/ci/test-branch/github.com%2Fisland-is%2Fisland.is/judicial-system-backend/j-s%2Frename-subpoena-id?env=ci&index=citest&_user_click_origin_=github) |
| [**`judicial-system-web`**](https://app.datadoghq.eu/ci/test-commit/github.com%2Fisland-is%2Fisland.is/judicial-system-web/j-s%2Frename-subpoena-id/1b269621afed06ea76acc8819a9456a19b950bd8?env=ci&index=citest&_user_click_origin_=github) | 0 | 0 | 0 | 344 | 0 | 3m 10.31s |  [Link](https://app.datadoghq.eu/ci/test-branch/github.com%2Fisland-is%2Fisland.is/judicial-system-web/j-s%2Frename-subpoena-id?env=ci&index=citest&_user_click_origin_=github) |
| [**`judicial-system-xrd-api`**](https://app.datadoghq.eu/ci/test-commit/github.com%2Fisland-is%2Fisland.is/judicial-system-xrd-api/j-s%2Frename-subpoena-id/1b269621afed06ea76acc8819a9456a19b950bd8?env=ci&index=citest&_user_click_origin_=github) | 0 | 0 | 0 | 6 | 0 | 33.41s |  [Link](https://app.datadoghq.eu/ci/test-branch/github.com%2Fisland-is%2Fisland.is/judicial-system-xrd-api/j-s%2Frename-subpoena-id?env=ci&index=citest&_user_click_origin_=github) |
</details>



author_association: NONE