Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

feat(native-app): Revert "feat: update vehicleList endpoint to V2" #16823

Merged
merged 2 commits into from
Nov 13, 2024

Conversation

thoreyjona
Copy link
Contributor

@thoreyjona thoreyjona commented Nov 12, 2024

This reverts commit 036f952.

What

Reverting since there is a typo in one prop from the api: https://github.com/island-is/island.is/blob/main/libs/api/domains/vehicles/src/lib/models/usersVehicles.model.ts#L235

Why

@thordurhhh will fix before next release so to prevent them needing to make sure to always returning both old and new prop I'm postponing releasing this until after next release (in 2 weeks).
Creating a new PR with this and keeping it open until release has been deployed.

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

  • New Features

    • Expanded vehicle data structure with additional fields for improved detail.
    • Updated vehicle listing queries to enhance data retrieval and organization.
    • Introduced new parameters for vehicle queries to refine data display.
  • Bug Fixes

    • Adjusted logic for next inspection date retrieval to ensure accurate display.
  • Refactor

    • Renamed GraphQL queries and hooks for consistency and clarity across the application.
    • Updated data extraction and handling to align with the new query structure.

@thoreyjona thoreyjona requested a review from a team as a code owner November 12, 2024 13:59
Copy link
Contributor

coderabbitai bot commented Nov 12, 2024

Walkthrough

The pull request introduces significant changes to the GraphQL fragments and queries related to vehicle data. The VehicleFragment is updated to a new type and includes numerous additional fields, while the ListVehicles query replaces the previous version, altering its input type and response structure. Corresponding updates are made across various components in the application, including adjustments to the hooks and data handling to align with the new query structure. Overall, these modifications enhance the vehicle data model and ensure consistency across the application.

Changes

File Path Change Summary
apps/native/app/src/graphql/fragments/vehicle.fragment.graphql Updated fragment type from VehicleListed to VehiclesVehicle, added multiple new fields, renamed canRegisterMilage to canRegisterMileage, removed make and colorName, and introduced a nested structure for nextInspection.
apps/native/app/src/graphql/queries/vehicles.graphql Replaced ListVehiclesV2 query with ListVehicles, changed input type from GetVehiclesListV2Input! to GetVehiclesForUserInput!, and renamed vehiclesListV2 to vehiclesList.
apps/native/app/src/screens/home/home.tsx Replaced useListVehiclesV2Query with useListVehiclesQuery, added showDeregeristered and showHistory parameters, and updated validation logic for vehicle data.
apps/native/app/src/screens/home/vehicles-module.tsx Renamed query types and hooks from ListVehiclesV2Query to ListVehiclesQuery, updated data validation logic and component props accordingly.
apps/native/app/src/screens/vehicles/components/vehicle-item.tsx Updated import and type references from ListVehiclesV2Query to ListVehiclesQuery, modified logic for next inspection date, and changed title parameter in navigation.
apps/native/app/src/screens/vehicles/vehicles.tsx Updated query and types from ListVehiclesV2Query to ListVehiclesQuery, adjusted data extraction logic, and modified pagination handling.

Possibly related PRs

Suggested labels

automerge

Suggested reviewers

  • thordurhhh
  • snaerseljan

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ 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 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.

@thoreyjona thoreyjona added the automerge Merge this PR as soon as all checks pass label Nov 12, 2024
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: 3

🧹 Outside diff range and nitpick comments (6)
apps/native/app/src/graphql/fragments/vehicle.fragment.graphql (2)

37-38: Field naming consistency improvement

The field requiresMileageRegistration is used alongside canRegisterMileage. For consistency in naming:

Consider renaming to maintain consistent terminology:

  requiresMileageRegistration
- canRegisterMileage
+ canRegisterMileageRegistration

15-23: Consider grouping related fields

The current field ordering mixes different concerns. Consider grouping related fields together for better maintainability:

Suggested grouping:

  1. Basic vehicle info (permno, regno, vin, type, etc.)
  2. Registration details (firstRegDate, registrationType, etc.)
  3. Status fields (outOfUse, vehicleStatus, plateStatus)
  4. Ownership fields (ownerPersidno, buyerPersidno, etc.)
  5. Inspection fields (all inspection-related fields)
  6. Mileage registration fields

This would make the fragment more organized and easier to maintain.

apps/native/app/src/graphql/queries/vehicles.graphql (1)

Line range hint 1-11: Consider maintaining API versioning strategy

The removal of the V2 suffix from the query name might impact the API versioning strategy. While this is a temporary revert, consider:

  1. Using a feature flag to toggle between V1 and V2 implementations
  2. Maintaining both versions until the next release
  3. Documenting the temporary nature of this revert in the schema

This approach would provide a smoother transition when re-implementing the V2 endpoint in two weeks.

apps/native/app/src/screens/home/vehicles-module.tsx (2)

173-173: Consider updating related documentation

The export statement correctly reflects the reversion to V1. Consider updating any related documentation or API references that might mention the V2 endpoint.


Line range hint 1-173: Consider version management strategy for the upcoming re-implementation

Since this reversion is temporary and will be re-implemented in two weeks:

  1. Consider adding TODO comments or creating tracking issues to ensure all V1 references are updated in the future PR
  2. Document the typo issue to prevent similar problems in future API updates
  3. Consider implementing version compatibility layer to handle such transitions more smoothly in the future

Would you like me to help create a tracking issue for the re-implementation?

apps/native/app/src/screens/vehicles/vehicles.tsx (1)

Line range hint 187-207: Simplify pagination logic and improve readability

The pagination logic could be improved in the following ways:

-          const pageNumber = res.data?.vehiclesList?.paging?.pageNumber ?? 1
-          const totalPages = res.data?.vehiclesList?.paging?.totalPages ?? 1
+          const paging = res.data?.vehiclesList?.paging
+          const pageNumber = paging?.pageNumber ?? 1
+          const totalPages = paging?.totalPages ?? 1

           // ...

-                  vehiclesList: {
-                    ...fetchMoreResult.vehiclesList,
-                    vehicleList: [
-                      ...(prev.vehiclesList?.vehicleList ?? []),
-                      ...(fetchMoreResult.vehiclesList?.vehicleList ?? []),
-                    ],
-                  },
+                  vehiclesList: {
+                    ...fetchMoreResult.vehiclesList,
+                    vehicleList: [
+                      ...(prev.vehiclesList?.vehicleList ?? []),
+                      ...(fetchMoreResult.vehiclesList?.vehicleList ?? []),
+                    ].filter(Boolean),
+                  },

These changes:

  1. Reduce repetitive optional chaining
  2. Add null filtering to ensure data integrity
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between a89215d and e9c277d.

📒 Files selected for processing (6)
  • apps/native/app/src/graphql/fragments/vehicle.fragment.graphql (1 hunks)
  • apps/native/app/src/graphql/queries/vehicles.graphql (1 hunks)
  • apps/native/app/src/screens/home/home.tsx (2 hunks)
  • apps/native/app/src/screens/home/vehicles-module.tsx (5 hunks)
  • apps/native/app/src/screens/vehicles/components/vehicle-item.tsx (3 hunks)
  • apps/native/app/src/screens/vehicles/vehicles.tsx (8 hunks)
🧰 Additional context used
📓 Path-based instructions (6)
apps/native/app/src/graphql/fragments/vehicle.fragment.graphql (1)

Pattern 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/native/app/src/graphql/queries/vehicles.graphql (1)

Pattern 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/native/app/src/screens/home/home.tsx (1)

Pattern 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/native/app/src/screens/home/vehicles-module.tsx (1)

Pattern 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/native/app/src/screens/vehicles/components/vehicle-item.tsx (1)

Pattern 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/native/app/src/screens/vehicles/vehicles.tsx (1)

Pattern 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."
🔇 Additional comments (11)
apps/native/app/src/screens/vehicles/components/vehicle-item.tsx (3)

6-6: LGTM: Type changes align with V2 endpoint reversion

The changes correctly revert the GraphQL query types while maintaining type safety.

Also applies to: 14-14


54-54: Verify the user experience impact of display changes

The vehicle identification has changed from using make to type, which might affect how users identify vehicles. Please confirm:

  1. Does type provide sufficient vehicle identification for users?
  2. Is color equivalent to the previous colorName in terms of user understanding?

Consider adding a more descriptive vehicle identifier, perhaps combining type with another field, to ensure clear vehicle identification for users.

Also applies to: 60-61


34-35: Verify schema structure for inspection date

The nested structure for accessing inspection date has changed. Let's verify this matches the GraphQL schema.

apps/native/app/src/screens/home/vehicles-module.tsx (3)

Line range hint 33-46: LGTM! Data validation logic preserved

The validation function maintains its original logic while correctly updating the type signature and data access path.


62-62: LGTM! Clean data access path update

The data access path has been correctly updated while preserving the component's existing functionality.


20-21: Verify consistent type usage across the codebase

The reversion from V2 to V1 types needs to be consistently applied across all components using these types.

✅ Verification successful

Consistent type usage verified

No lingering V2 references found in the codebase.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for any remaining V2 references that might have been missed
rg "ListVehiclesV2|useListVehiclesV2" --type ts

Length of output: 49

apps/native/app/src/screens/vehicles/vehicles.tsx (3)

Line range hint 80-84: LGTM: Query usage is correct

The query implementation is clean and properly configured with the input variables.


17-18: Verify the impact of reverting V2 types

The changes from V2 to non-V2 versions align with the PR objective. However, we should verify that all dependent components are updated accordingly.

#!/bin/bash
# Search for any remaining V2 references that might need updating
rg -l "ListVehiclesV2|vehiclesListV2" apps/native/app/src/

Also applies to: 35-35


138-138: Verify the uniqueness of VIN as a key

The key extractor now uses item.vin instead of item.permno. While VINs are typically unique, please ensure that:

  1. VIN is never null or undefined
  2. The combination of VIN and index provides a unique key for all scenarios
#!/bin/bash
# Search for VIN handling in the codebase
ast-grep --pattern 'item.vin' 

Also applies to: 150-150

apps/native/app/src/screens/home/home.tsx (2)

58-58: LGTM: Import statement correctly reverted

The change correctly reverts the import statement from V2 to the original version, aligning with the PR objective.


177-183: Verify the impact of new query parameters

While the reversion of the query hook is correct, please verify:

  1. That these parameters (showDeregeristered and showHistory) existed in the original version
  2. The UI implications of setting both parameters to false if the app was previously showing deregistered or historical vehicles
✅ Verification successful

Parameters showDeregeristered and showHistory verified

The parameters exist and are correctly set to false. Ensure that the UI updates appropriately to handle the absence of deregistered or historical vehicles.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check if these parameters existed in the original version and their usage

# Search for previous usage of these parameters
rg -B 3 -A 3 'showDeregeristered|showHistory' --type ts

# Check the GraphQL schema for these parameters
ast-grep --pattern 'input GetVehiclesForUserInput {
  $$$
  showDeregeristered: $_
  showHistory: $_
  $$$
}'

Length of output: 19591

@kodiakhq kodiakhq bot merged commit de4bcc8 into main Nov 13, 2024
23 checks passed
@kodiakhq kodiakhq bot deleted the feat/revert-vehicleList-update branch November 13, 2024 04:24
jonnigs pushed a commit that referenced this pull request Nov 26, 2024
…16823)

This reverts commit 036f952.

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
@coderabbitai coderabbitai bot mentioned this pull request Dec 5, 2024
6 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
automerge Merge this PR as soon as all checks pass
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants