-
Notifications
You must be signed in to change notification settings - Fork 61
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
chore(skilavottord): Inspect why traffic endpoint is not always returning data #16151
Conversation
WalkthroughThe changes introduce a new state variable in the Changes
Possibly related PRs
Suggested labels
Suggested reviewers
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? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
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)
Other keywords and placeholders
Documentation and Community
|
There was a problem hiding this 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
🧹 Outside diff range and nitpick comments (2)
apps/skilavottord/web/screens/DeregisterVehicle/Confirm/Confirm.tsx (1)
141-145
: LGTM: Query callback enhances monitoring, with room for improvementThe addition of the
onCompleted
callback toSkilavottordVehicleReadyToDeregisteredQuery
is a good step towards better monitoring of the traffic data retrieval process. It aligns well with the PR objectives.However, there's room for a small improvement in the null check:
Consider using an optional chain for a more concise null check:
onCompleted: (data) => { if (data?.skilavottordVehicleReadyToDeregistered) { setVehicleReadyToDeregisteredQueryCompleted(true) } },This change will make the code more robust and align with TypeScript best practices. Would you like me to implement this change for you?
🧰 Tools
Biome
[error] 142-142: Change to an optional chain.
Unsafe fix: Change to an optional chain.
(lint/complexity/useOptionalChain)
apps/skilavottord/ws/src/app/modules/samgongustofa/samgongustofa.service.ts (1)
350-392
: LGTM! Changes align well with PR objectives.The implemented changes effectively address the issue of inconsistent data return from the traffic endpoint. The additional logging will greatly facilitate monitoring and debugging. These improvements align perfectly with the stated PR objectives.
Consider using type assertion for better type safety.
For improved type safety, consider using a type assertion when reducing the traffic data:
const traffic = Object.values(result.data).reduce<Traffic>( (prev, current) => new Date(prev.useDate) > new Date(current.useDate) ? prev : current );This ensures that TypeScript knows the exact type of
traffic
without the need for an additional type assertion.Optimize performance by avoiding multiple
getShortPermno
calls.To slightly improve performance, consider storing the result of
getShortPermno(permno)
in a variable before the logging statements:const shortPermno = getShortPermno(permno); logger.info(`car-recycling: Got traffic data for ${shortPermno}`, { // ... }); if (!traffic.outInStatus) { logger.warn(`car-recycling: No traffic data being returned for ${shortPermno}`, { // ... }); }This avoids calling
getShortPermno
multiple times with the same argument.
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
📒 Files selected for processing (2)
- apps/skilavottord/web/screens/DeregisterVehicle/Confirm/Confirm.tsx (3 hunks)
- apps/skilavottord/ws/src/app/modules/samgongustofa/samgongustofa.service.ts (1 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
apps/skilavottord/web/screens/DeregisterVehicle/Confirm/Confirm.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/skilavottord/ws/src/app/modules/samgongustofa/samgongustofa.service.ts (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."
Biome
apps/skilavottord/web/screens/DeregisterVehicle/Confirm/Confirm.tsx
[error] 142-142: Change to an optional chain.
Unsafe fix: Change to an optional chain.
(lint/complexity/useOptionalChain)
🔇 Additional comments not posted (3)
apps/skilavottord/web/screens/DeregisterVehicle/Confirm/Confirm.tsx (3)
104-107
: LGTM: New state variable improves query flow controlThe introduction of
vehicleReadyToDeregisteredQueryCompleted
state variable is a good addition. It helps in controlling the flow of queries by ensuring that the traffic query only runs after confirming the vehicle is ready for deregistration. This aligns well with the PR objective of enhancing the functionality of the traffic endpoint.
155-155
: LGTM: Skip condition optimizes query executionThe addition of the
skip
condition toSkilavottordTrafficQuery
is an excellent optimization. It ensures that the traffic query is only executed after confirming that the vehicle is ready for deregistration. This change directly addresses the PR objective of invoking the traffic endpoint only when necessary, potentially improving both performance and reliability.
Line range hint
1-359
: Summary: Changes effectively address PR objectivesThe modifications in this file successfully address the main objectives of the PR:
- The new state variable and query callbacks enhance monitoring of the traffic data retrieval process.
- The skip condition ensures that the traffic endpoint is only invoked when necessary.
- These changes collectively contribute to improving the consistency and reliability of data returned by the traffic endpoint.
The code adheres to NextJS and TypeScript best practices, with a minor suggestion for improvement in the null check. Overall, these changes should effectively resolve the issues outlined in ticket TS-919.
🧰 Tools
Biome
[error] 142-142: Change to an optional chain.
Unsafe fix: Change to an optional chain.
(lint/complexity/useOptionalChain)
Datadog ReportAll test runs ✅ 35 Total Test Services: 0 Failed, 34 Passed Test ServicesThis report shows up to 10 services
🔻 Code Coverage Decreases vs Default Branch (1)
|
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #16151 +/- ##
==========================================
- Coverage 36.63% 36.63% -0.01%
==========================================
Files 6771 6771
Lines 139472 139476 +4
Branches 39668 39670 +2
==========================================
- Hits 51100 51099 -1
- Misses 88372 88377 +5 Flags with carried forward coverage won't be shown. Click here to find out more.
... and 1 file with indirect coverage changes Continue to review full report in Codecov by Sentry.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm 💯
…ning data (#16151) - Added loggers - make sure Traffic is only called when needed Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
* chore(skilavottord): Inspect why traffic endpoint is not always returning data (#16151) - Added loggers - make sure Traffic is only called when needed Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com> * fix(skilavottord): Error when trying to view and save recycling companies (#16159) - Fix path when trying to view recycling company - Fix error when trying to save recycling company Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com> --------- Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
…ning data (#16151) - Added loggers - make sure Traffic is only called when needed Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
TS-919
What
Checklist:
Summary by CodeRabbit
New Features
Bug Fixes