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

fix: send only name and value in check_policies and expenses calls #3459

Merged
merged 6 commits into from
Feb 6, 2025

Conversation

arjunaj5
Copy link
Contributor

@arjunaj5 arjunaj5 commented Jan 30, 2025

Clickup

https://app.clickup.com/t/86cxv4pb9

Code Coverage

Please add code coverage here

UI Preview

Please add screenshots for UI changes

Summary by CodeRabbit

  • Improvements
    • Enhanced handling of custom properties in expense and policy transactions.
    • Standardized custom fields representation with explicit name and value keys.
    • Updated mock data to include additional properties and modifications for better structure.

Copy link

coderabbitai bot commented Jan 30, 2025

Walkthrough

In a stylish transformation worthy of a blockbuster, the ExpensesService and PolicyService have undergone a precision upgrade in handling custom properties. The changes involve mapping transaction.custom_properties into a structured array of objects with explicit name and value properties, ensuring a more robust and predictable representation of custom fields across the platform.

Changes

File Change Summary
src/app/core/services/platform/v1/spender/expenses.service.ts Transformed custom_fields mapping to create structured objects from transaction.custom_properties
src/app/core/services/policy.service.ts Updated transformTo method to map custom_properties into objects with name and value keys; Added TxnCustomProperties import
src/app/core/mock-data/platform-policy-expense.data.ts Modified platformPolicyExpenseData2 to include new properties and changes to custom_fields; updated related mock data objects
src/app/core/services/policy.service.spec.ts Changed test suite descriptor from describe to fdescribe for focused testing of PolicyService

Suggested Reviewers

  • Chethan-Fyle
  • mvaishnavi
  • Dimple16

Possibly related PRs

Suggested Labels

size/M

Poem

Whisper of code, a stylish dance 🕺
Custom fields now leap and prance
Properties mapped with swagger bold
A transformation, pure Rajini gold! 💥
Precision strikes, data takes flight! ✨

Tip

🌐 Web search-backed reviews and chat
  • We have enabled web search-based reviews and chat for all users. This feature allows CodeRabbit to access the latest documentation and information on the web.
  • You can disable this feature by setting web_search: false in the knowledge_base settings.
  • Please share any feedback in the Discord discussion.
✨ Finishing Touches
  • 📝 Generate Docstrings (Beta)

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 generate docstrings to generate docstrings for this PR. (Beta)
  • @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.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

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.

@github-actions github-actions bot added the size/XS Extra Small PR label Jan 30, 2025
@arjunaj5 arjunaj5 requested a review from mvaishnavi January 30, 2025 07:02
custom_fields: transaction.custom_properties.map((customProperty) => ({
name: customProperty.name,
value: customProperty.value,
})),
Copy link
Contributor Author

Choose a reason for hiding this comment

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

transformTO method

custom_fields: transaction.custom_properties.map((customProperty: TxnCustomProperties) => ({
name: customProperty.name,
value: customProperty.value,
})),
Copy link
Contributor Author

Choose a reason for hiding this comment

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

transformTO method

Copy link

@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: 1

📜 Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a5ad293 and 83c12fb.

📒 Files selected for processing (2)
  • src/app/core/services/platform/v1/spender/expenses.service.ts (1 hunks)
  • src/app/core/services/policy.service.ts (2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: build (12.x)
🔇 Additional comments (2)
src/app/core/services/policy.service.ts (2)

17-17: Mind-blowing import statement, I tell you!

The import of TxnCustomProperties model brings type safety to our custom properties mapping. Simply superb!


50-53: What a style, what a style! Custom properties transformation is now razor-sharp!

The transformation now precisely picks only the required name and value fields, making the API payload clean and efficient. This is exactly what we wanted, mind it!

Comment on lines +317 to +320
custom_fields: transaction.custom_properties.map((customProperty) => ({
name: customProperty.name,
value: customProperty.value,
})),
Copy link

Choose a reason for hiding this comment

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

🧹 Nitpick (assertive)

Listen carefully! The transformation is powerful, but needs a small punch!

While the implementation is spot on, let's add type annotation for better type safety, just like we did in policy.service.ts.

Apply this style enhancement:

-      custom_fields: transaction.custom_properties.map((customProperty) => ({
+      custom_fields: transaction.custom_properties.map((customProperty: TxnCustomProperties) => ({
        name: customProperty.name,
        value: customProperty.value,
      })),

Committable suggestion skipped: line range outside the PR's diff.

@github-actions github-actions bot added size/S Small PR and removed size/XS Extra Small PR labels Feb 6, 2025
Copy link

@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: 1

📜 Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 83c12fb and 084260b.

📒 Files selected for processing (2)
  • src/app/core/mock-data/platform-policy-expense.data.ts (0 hunks)
  • src/app/core/services/policy.service.spec.ts (1 hunks)
💤 Files with no reviewable changes (1)
  • src/app/core/mock-data/platform-policy-expense.data.ts
🧰 Additional context used
🪛 Biome (1.9.4)
src/app/core/services/policy.service.spec.ts

[error] 32-33: Don't focus the test.

The 'only' method is often used for debugging or during implementation. It should be removed before deploying to production.
Consider removing 'only' to ensure all tests are executed.
Unsafe fix: Remove focus from test.

(lint/suspicious/noFocusedTests)

⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: gitStream.cm
  • GitHub Check: build (12.x)

@@ -30,7 +30,7 @@ import { fileObject4 } from '../mock-data/file-object.data';
import { unspecifiedCategory } from '../mock-data/org-category.data';
import { eCCCData1 } from '../mock-data/corporate-card-expense-unflattened.data';

describe('PolicyService', () => {
fdescribe('PolicyService', () => {
Copy link

Choose a reason for hiding this comment

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

🧹 Nitpick (assertive)

⚠️ Potential issue

Remove Focused Test Suite

My friend, fdescribe is like using a superpower meant only for debugging—but in production, even Rajinikanth leaves nothing to chance. Replace fdescribe with describe so that all tests run, not just your favorite ones.

- fdescribe('PolicyService', () => {
+ describe('PolicyService', () => {
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
fdescribe('PolicyService', () => {
describe('PolicyService', () => {
🧰 Tools
🪛 Biome (1.9.4)

[error] 32-33: Don't focus the test.

The 'only' method is often used for debugging or during implementation. It should be removed before deploying to production.
Consider removing 'only' to ensure all tests are executed.
Unsafe fix: Remove focus from test.

(lint/suspicious/noFocusedTests)

Copy link

github-actions bot commented Feb 6, 2025

Unit Test Coverage % values
Statements 96.07% ( 19753 / 20559 )
Branches 91.13% ( 10852 / 11908 )
Functions 94.37% ( 5869 / 6219 )
Lines 96.13% ( 18870 / 19629 )

@arjunaj5 arjunaj5 merged commit 7081b9d into master Feb 6, 2025
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size/S Small PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants