Skip to content

fix(j-s): rename subpoenaId to policeSubpoenaId #18836

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

thorhildurt
Copy link
Member

@thorhildurt thorhildurt commented Apr 22, 2025

Rename subpoenaId to policeSubpoenaId

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

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.

@thorhildurt thorhildurt requested a review from a team as a code owner April 22, 2025 15:51
Copy link
Contributor

coderabbitai bot commented Apr 22, 2025

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
.../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
.../web/src/components/FormProvider/limitedAccessCase.graphql
.../web/src/routes/Defender/Cases/defenderCases.graphql
.../web/src/routes/Shared/Cases/cases.graphql
.../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)

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
Loading

Suggested labels

deprecated:automerge


📜 Recent review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between fd50e48 and d68f8f3.

📒 Files selected for processing (1)
  • apps/judicial-system/xrd-api/src/app/app.service.ts (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • apps/judicial-system/xrd-api/src/app/app.service.ts

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.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • 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 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 for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@thorhildurt thorhildurt self-assigned this Apr 22, 2025
Copy link

nx-cloud bot commented Apr 22, 2025

View your CI Pipeline Execution ↗ for commit d68f8f3.

Command Status Duration Result
nx run-many --projects judicial-system-backend ... ✅ Succeeded 16m 39s View ↗
nx run-many --target=build --projects=judicial-... ✅ Succeeded 6m 21s View ↗
nx run-many --projects judicial-system-api,judi... ✅ Succeeded 3m 14s View ↗
nx run-many -t lint --output-style=static --pro... ✅ Succeeded 2s View ↗
nx run-many --target=codegen/frontend-client --... ✅ Succeeded 13s View ↗
nx run-many --target=build --projects=judicial-... ✅ Succeeded 27s View ↗
nx run-many --target=codegen/backend-schema --a... ✅ Succeeded 25s View ↗
nx run-many --target=codegen/backend-client --a... ✅ Succeeded 22s View ↗
Additional runs (1) ✅ Succeeded ... View ↗

☁️ Nx Cloud last updated this comment at 2025-04-23 11:31:24 UTC

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
apps/judicial-system/backend/migrations/20250422152214-update-supoena-id.js (1)

1-3: Remove redundant 'use strict' directive

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

-'use strict'

 module.exports = {
🧰 Tools
🪛 Biome (1.9.4)

[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)

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 20d7c28 and 04b650b.

📒 Files selected for processing (14)
  • 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)
🧰 Additional context used
📓 Path-based instructions (1)
`apps/**/*`: "Confirm that the code adheres to the following: - NextJS best practices, including file structure, API routes, and static generation methods. - Efficient state manage...

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
🧠 Learnings (13)
apps/judicial-system/web/src/utils/hooks/useSubpoena/subpoena.graphql (1)
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.
apps/judicial-system/backend/src/app/modules/police/models/createSubpoena.response.ts (2)
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.
apps/judicial-system/backend/src/app/modules/subpoena/internalSubpoena.controller.ts (3)
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.
apps/judicial-system/web/src/routes/Defender/Cases/defenderCases.graphql (1)
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.
apps/judicial-system/web/src/routes/Shared/Cases/cases.graphql (1)
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.
apps/judicial-system/backend/src/app/modules/police/police.service.ts (1)
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.
apps/judicial-system/backend/src/app/modules/subpoena/guards/policeSubpoenaExists.guard.ts (3)
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.
apps/judicial-system/web/src/components/FormProvider/limitedAccessCase.graphql (1)
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.
apps/judicial-system/backend/src/app/modules/subpoena/models/subpoena.model.ts (1)
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.
apps/judicial-system/backend/src/app/modules/subpoena/subpoena.service.ts (2)
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.
apps/judicial-system/web/src/components/FormProvider/case.graphql (1)
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.
apps/judicial-system/web/src/utils/hooks/useSubpoena/index.ts (2)
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.
apps/judicial-system/api/src/app/modules/subpoena/models/subpoena.model.ts (1)
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.
🪛 Biome (1.9.4)
apps/judicial-system/backend/migrations/20250422152214-update-supoena-id.js

[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)

🔇 Additional comments (23)
apps/judicial-system/web/src/routes/Defender/Cases/defenderCases.graphql (1)

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.

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

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.

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

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.

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

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.

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

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.

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

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.

apps/judicial-system/web/src/components/FormProvider/limitedAccessCase.graphql (1)

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.

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

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.

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

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.

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

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.

apps/judicial-system/web/src/components/FormProvider/case.graphql (2)

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.

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

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.

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

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.

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

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.

@datadog-island-is
Copy link

datadog-island-is bot commented Apr 22, 2025

Datadog Report

All test runs 1b26962 🔗

4 Total Test Services: 0 Failed, 4 Passed

Test Services
Service Name Failed Known Flaky New Flaky Passed Skipped Total Time Test Service View
judicial-system-api 0 0 0 61 0 14.81s Link
judicial-system-backend 0 0 0 22353 0 16m 35.19s Link
judicial-system-web 0 0 0 344 0 3m 10.31s Link
judicial-system-xrd-api 0 0 0 6 0 33.41s Link

@oddsson oddsson enabled auto-merge April 23, 2025 10:58
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
apps/judicial-system/xrd-api/src/app/app.service.ts (1)

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.

-      // 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.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 04b650b and fd50e48.

📒 Files selected for processing (8)
  • 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)
🚧 Files skipped from review as they are similar to previous changes (4)
  • 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
🧰 Additional context used
📓 Path-based instructions (1)
`apps/**/*`: "Confirm that the code adheres to the following: - NextJS best practices, including file structure, API routes, and static generation methods. - Efficient state manage...

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
🧠 Learnings (4)
apps/judicial-system/backend/src/app/modules/subpoena/test/internalSubpoenaController/deliverSubpoenaRevocationToPolice.spec.ts (2)
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.
apps/judicial-system/xrd-api/src/app/app.service.ts (1)
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.
apps/judicial-system/backend/src/app/modules/subpoena/guards/test/policeSubpoenaExistsGuard.spec.ts (2)
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.
apps/judicial-system/xrd-api/src/app/app.controller.ts (1)
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.
🔇 Additional comments (12)
apps/judicial-system/backend/src/app/modules/subpoena/test/internalSubpoenaController/deliverSubpoenaRevocationToPolice.spec.ts (1)

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.

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

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.

apps/judicial-system/xrd-api/src/app/app.controller.ts (4)

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.

apps/judicial-system/xrd-api/src/app/app.service.ts (3)

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.

@thorhildurt thorhildurt disabled auto-merge April 23, 2025 11:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants