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 Edit Expenses changes #204

Merged
merged 7 commits into from
Jul 12, 2024
Merged

Fix Edit Expenses changes #204

merged 7 commits into from
Jul 12, 2024

Conversation

Hrishabh17
Copy link
Contributor

@Hrishabh17 Hrishabh17 commented Jul 11, 2024

Summary by CodeRabbit

  • New Features

    • Added an optional skip_update parameter in expense object creation to control update behavior.
  • Performance Improvements

    • Adjusted polling interval from 1 to 5 in task processing for enhanced efficiency.
  • Dependencies

    • Updated fyle-integrations-platform-connector to version 1.38.4.
  • Tests

    • Modified test configurations and fixtures to align with the updated expense object creation parameters.

Copy link

coderabbitai bot commented Jul 11, 2024

Walkthrough

The primary updates include adding a skip_update parameter to the create_expense_objects method in the Expense class and updating its usage in the update_non_exported_expenses function. Additionally, the fyle-integrations-platform-connector version was upgraded, and the polling interval in the Sage Desktop API settings was increased from 1 to 5. Minor fixture modifications were made in the test files.

Changes

Files Change Summaries
apps/fyle/models.py Added skip_update parameter to create_expense_objects function in the Expense class.
apps/fyle/tasks.py Modified update_non_exported_expenses to pass skip_update=True to create_expense_objects.
requirements.txt Updated fyle-integrations-platform-connector from 1.38.1 to 1.38.4.
sage_desktop_api/settings.py Changed polling interval from 1 to 5.
sage_desktop_api/tests/settings.py Updated polling interval parameter from 1 to 5 in the test configuration.
tests/test_fyle/fixtures.py Removed the nested report dictionary, affecting fields related to approvals, reimbursement, and payment processing.

Poem

In the code where changes flow,
Parameters come and settings grow.
Polling now takes five instead,
As updates to expenses are thoughtfully read.
Connectors rise with versions new,
The tasks proceed with work to do.
🐇✨ Happy coding through and through!


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>.
    • 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 generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @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 as 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.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration 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.

Copy link

Tests Skipped Failures Errors Time
136 0 💤 0 ❌ 0 🔥 10.707s ⏱️

Copy link

Tests Skipped Failures Errors Time
136 0 💤 0 ❌ 0 🔥 10.412s ⏱️

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: CHILL

Commits

Files that changed from the base of the PR and between 2fbd44c and 1d32161.

Files selected for processing (1)
  • apps/fyle/queue.py (1 hunks)
Additional comments not posted (1)
apps/fyle/queue.py (1)

86-86: Ensure no sensitive information is logged.

While logging the body of the request can be useful for debugging, ensure that no sensitive information (e.g., personal data, financial information) is included in the logs. Consider sanitizing the data before logging.

@@ -83,6 +83,7 @@ def async_handle_webhook_callback(body: dict, workspace_id: int) -> None:

elif body.get('action') == 'UPDATED_AFTER_APPROVAL' and body.get('data') and body.get('resource') == 'EXPENSE':
org_id = body['data']['org_id']
logger.info("Body: {}".format(body))
logger.info("| Updating non-exported expenses through webhook | Content: {{WORKSPACE_ID: {} Payload: {}}}".format(workspace_id, body.get('data')))
Copy link

Choose a reason for hiding this comment

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

Correct the logging format.

The logging statement uses double curly braces which might be a formatting error. The correct format should be a single pair of curly braces.

- logger.info("| Updating non-exported expenses through webhook | Content: {{WORKSPACE_ID: {} Payload: {}}}".format(workspace_id, body.get('data')))
+ logger.info("| Updating non-exported expenses through webhook | Content: {WORKSPACE_ID: {} Payload: {}}".format(workspace_id, body.get('data')))
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
logger.info("| Updating non-exported expenses through webhook | Content: {{WORKSPACE_ID: {} Payload: {}}}".format(workspace_id, body.get('data')))
logger.info("| Updating non-exported expenses through webhook | Content: {WORKSPACE_ID: {} Payload: {}}".format(workspace_id, body.get('data')))

Copy link

Tests Skipped Failures Errors Time
136 0 💤 2 ❌ 19 🔥 19.537s ⏱️

Copy link

Tests Skipped Failures Errors Time
136 0 💤 2 ❌ 19 🔥 18.838s ⏱️

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: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 1d32161 and 6063fa0.

Files selected for processing (4)
  • apps/fyle/models.py (4 hunks)
  • apps/fyle/tasks.py (1 hunks)
  • requirements.txt (1 hunks)
  • tests/test_fyle/fixtures.py (1 hunks)
Files skipped from review due to trivial changes (1)
  • requirements.txt
Additional comments not posted (3)
apps/fyle/tasks.py (1)

148-148: LGTM! But verify the function usage in the codebase.

The code changes are approved.

However, ensure that all function calls to update_non_exported_expenses are correct and non-breaking.

apps/fyle/models.py (1)

Line range hint 119-140:
LGTM! But verify the function usage in the codebase.

The code changes are approved.

However, ensure that all function calls to create_expense_objects match the new signature and are non-breaking.

Verification successful

Ensure all function calls to create_expense_objects match the new signature and are non-breaking.

  • apps/fyle/tasks.py:
    • Line: 47: expense_objects = Expense.create_expense_objects(expenses, workspace_id)
    • Line: 57: Expense.create_expense_objects(expense_objects, expense.workspace_id, skip_update=True)

The function calls in apps/fyle/tasks.py match the new signature of create_expense_objects with the skip_update parameter.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify all function calls to `create_expense_objects` in the codebase.

# Test: Search for the function usage. Expect: Only occurances of the new signature.
rg --type python -A 5 $'create_expense_objects'

Length of output: 77


Script:

#!/bin/bash
# Description: Verify all function calls to `create_expense_objects` in the codebase.

# Test: Search for the function usage. Expect: Only occurrences of the new signature.
rg 'create_expense_objects' --glob '**/*.py' -A 5

Length of output: 8236

tests/test_fyle/fixtures.py (1)

Line range hint 1-1:
Ensure tests are updated to reflect the removal of the report field.

The removal of the report dictionary field might impact tests that rely on this data. Ensure the tests are updated accordingly.

Copy link

Tests Skipped Failures Errors Time
136 0 💤 0 ❌ 0 🔥 10.628s ⏱️

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: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 6063fa0 and 5dcaa8f.

Files selected for processing (2)
  • apps/fyle/models.py (2 hunks)
  • apps/fyle/tasks.py (1 hunks)
Files skipped from review as they are similar to previous changes (2)
  • apps/fyle/models.py
  • apps/fyle/tasks.py

Copy link

Tests Skipped Failures Errors Time
136 0 💤 0 ❌ 0 🔥 10.670s ⏱️

Copy link

Tests Skipped Failures Errors Time
136 0 💤 0 ❌ 0 🔥 10.850s ⏱️

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: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 5dcaa8f and bbcfb77.

Files selected for processing (1)
  • apps/fyle/tasks.py (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • apps/fyle/tasks.py

@Hrishabh17 Hrishabh17 changed the title fixing payload logging Fix Edit Expenses changes Jul 11, 2024
Copy link

Tests Skipped Failures Errors Time
136 0 💤 0 ❌ 0 🔥 10.274s ⏱️

@Hrishabh17 Hrishabh17 requested a review from ashwin1111 July 11, 2024 13:37
Copy link

Tests Skipped Failures Errors Time
136 0 💤 0 ❌ 0 🔥 10.641s ⏱️

Copy link

Tests Skipped Failures Errors Time
136 0 💤 0 ❌ 0 🔥 10.457s ⏱️

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: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between bbcfb77 and cdcd0b7.

Files selected for processing (5)
  • apps/fyle/models.py (2 hunks)
  • apps/fyle/tasks.py (1 hunks)
  • sage_desktop_api/settings.py (1 hunks)
  • sage_desktop_api/tests/settings.py (1 hunks)
  • tests/test_fyle/fixtures.py (3 hunks)
Files skipped from review due to trivial changes (2)
  • sage_desktop_api/settings.py
  • sage_desktop_api/tests/settings.py
Files skipped from review as they are similar to previous changes (3)
  • apps/fyle/models.py
  • apps/fyle/tasks.py
  • tests/test_fyle/fixtures.py

@Hrishabh17 Hrishabh17 merged commit 4b61d23 into master Jul 12, 2024
1 check passed
Hrishabh17 added a commit that referenced this pull request Jul 15, 2024
* fixing payload logging

* fix edit expenses

* bump version of platform-connector, add fix for expense update

* add logger

* remove extra loggers

* increase poll

* fix created_at, updated_at null constraint
@coderabbitai coderabbitai bot mentioned this pull request Sep 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants