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

Max retry for exports #662

Merged
merged 5 commits into from
Aug 29, 2024
Merged

Max retry for exports #662

merged 5 commits into from
Aug 29, 2024

Conversation

Ashutosh619-sudo
Copy link
Contributor

@Ashutosh619-sudo Ashutosh619-sudo commented Aug 21, 2024

Summary by CodeRabbit

  • New Features

    • Introduced a function to validate whether an export should be skipped based on specific conditions.
    • Enhanced scheduling functions to allow for more control over the export process with an additional parameter.
  • Bug Fixes

    • Improved error handling by logging skipped exports due to unresolved errors, enhancing process traceability.
  • Tests

    • Updated test functions to accommodate the new parameter in scheduling functions, ensuring proper verification of the updated logic.

Copy link

coderabbitai bot commented Aug 21, 2024

Walkthrough

The recent changes to the QuickBooks Online application introduce a new function, validate_failing_export, which determines if an export should be skipped based on specific conditions. Additionally, the scheduling functions have been modified to accept an interval_hours parameter, improving control over the export process and enhancing error management and traceability in expense handling.

Changes

Files Change Summary
apps/quickbooks_online/queue.py Introduced validate_failing_export for error assessment; updated scheduling functions to include interval_hours, enhancing error handling.
tests/test_quickbooks_online/test_tasks.py Updated test functions to include a new parameter for scheduling functions, aligning with changes in the primary implementation of expense creation.

Poem

🐰 In the garden of code, where bunnies play,
New features bloom bright, chasing errors away.
With intervals set, and exports refined,
Each task hops forward, with joy intertwined.
So here’s to the changes, let’s dance and cheer,
For smoother operations, and no more fear! 🎉


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

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.

Copy link

Tests Skipped Failures Errors Time
249 0 💤 0 ❌ 0 🔥 1m 7s ⏱️

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

Outside diff range, codebase verification and nitpick comments (2)
apps/workspaces/actions.py (1)

Update Function Calls to Include interval_hours Parameter

The export_to_qbo function is used in several places, but the new interval_hours parameter is not included in these calls. Ensure that all instances of export_to_qbo are updated to match the new function signature.

  • Files to update:
    • apps/workspaces/views.py
    • apps/workspaces/tasks.py
    • apps/fyle/tasks.py
Analysis chain

Line range hint 289-359: LGTM! But verify the function usage in the codebase.

The addition of the interval_hours parameter is consistent and correctly integrated into the scheduling function calls.

However, ensure that all calls to export_to_qbo in the codebase correctly handle the new interval_hours parameter.

Run the following script to verify the function usage:

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify all function calls to `export_to_qbo` match the new signature.

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

Length of output: 68


Script:

#!/bin/bash
# Description: Verify all function calls to `export_to_qbo` match the new signature.

# Test: Search for the function usage. Expect: Only occurrences of the new signature.
rg --type py -A 5 $'export_to_qbo'

Length of output: 4565

apps/quickbooks_online/queue.py (1)

22-30: Inconsistent timezone usage with datetime.now().

The use of datetime.now() is inconsistent across the codebase, with some instances using timezone.utc and others not. This inconsistency could lead to timezone-related issues. It is recommended to review and standardize the usage of datetime.now() with timezone.utc where appropriate.

  • Consider reviewing the following files for timezone consistency:
    • tests/test_workspaces/test_views.py
    • tests/test_quickbooks_online/conftest.py
    • apps/workspaces/actions.py
    • apps/quickbooks_online/queue.py
Analysis chain

Verify timezone consistency.

The use of datetime.now() with timezone.utc should be consistent across the codebase to avoid timezone-related issues.

Run the following script to verify timezone usage:

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the consistency of timezone usage with `datetime.now()`.

# Test: Search for `datetime.now()` usage. Expect: Consistent use of `timezone.utc`.
rg --type python $'datetime.now()'

Length of output: 66


Script:

#!/bin/bash
# Description: Verify the consistency of timezone usage with `datetime.now()`.

# Test: Search for `datetime.now()` usage. Expect: Consistent use of `timezone.utc`.
rg 'datetime.now()'

Length of output: 10286

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 349e2f7 and e13add6.

Files selected for processing (3)
  • apps/quickbooks_online/queue.py (10 hunks)
  • apps/workspaces/actions.py (2 hunks)
  • tests/test_quickbooks_online/test_tasks.py (5 hunks)
Additional comments not posted (10)
apps/quickbooks_online/queue.py (5)

Line range hint 33-54: LGTM!

The integration of interval_hours and error validation in schedule_bills_creation is consistent and correctly implemented.


Line range hint 105-126: LGTM!

The integration of interval_hours and error validation in schedule_cheques_creation is consistent and correctly implemented.


Line range hint 154-175: LGTM!

The integration of interval_hours and error validation in schedule_journal_entry_creation is consistent and correctly implemented.


Line range hint 202-225: LGTM!

The integration of interval_hours and error validation in schedule_credit_card_purchase_creation is consistent and correctly implemented.


Line range hint 254-275: LGTM!

The integration of interval_hours and error validation in schedule_qbo_expense_creation is consistent and correctly implemented.

tests/test_quickbooks_online/test_tasks.py (5)

1029-1029: LGTM!

The addition of the parameter in test_schedule_credit_card_purchase_creation aligns with the updated function signature.


1046-1046: LGTM!

The addition of the parameter in test_schedule_bills_creation aligns with the updated function signature.


1063-1063: LGTM!

The addition of the parameter in test_schedule_cheques_creation aligns with the updated function signature.


1080-1080: LGTM!

The addition of the parameter in test_schedule_qbo_expense_creation aligns with the updated function signature.


1097-1097: LGTM!

The addition of the parameter in test_schedule_journal_entry_creation aligns with the updated function signature.

Copy link

codecov bot commented Aug 21, 2024

Codecov Report

Attention: Patch coverage is 76.19048% with 10 lines in your changes missing coverage. Please review.

Project coverage is 94.48%. Comparing base (e01a820) to head (e13add6).
Report is 11 commits behind head on master.

Files Patch % Lines
apps/quickbooks_online/queue.py 76.19% 10 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #662      +/-   ##
==========================================
- Coverage   94.99%   94.48%   -0.51%     
==========================================
  Files          61       61              
  Lines        4716     4790      +74     
==========================================
+ Hits         4480     4526      +46     
- Misses        236      264      +28     
Files Coverage Δ
apps/workspaces/actions.py 95.43% <ø> (-1.45%) ⬇️
apps/quickbooks_online/queue.py 94.01% <76.19%> (-5.99%) ⬇️

... and 1 file with indirect coverage changes

@ashwin1111 ashwin1111 removed their request for review August 22, 2024 09:07
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 e13add6 and 4543e76.

Files selected for processing (2)
  • apps/quickbooks_online/queue.py (10 hunks)
  • tests/test_quickbooks_online/test_tasks.py (6 hunks)
Files skipped from review as they are similar to previous changes (1)
  • tests/test_quickbooks_online/test_tasks.py
Additional comments not posted (5)
apps/quickbooks_online/queue.py (5)

Line range hint 33-54: LGTM!

The function is correctly implemented with the new parameter and function call integrated properly.

The code changes are approved.


Line range hint 105-126: LGTM!

The function is correctly implemented with the new parameter and function call integrated properly.

The code changes are approved.


Line range hint 154-175: LGTM!

The function is correctly implemented with the new parameter and function call integrated properly.

The code changes are approved.


Line range hint 202-225: LGTM!

The function is correctly implemented with the new parameter and function call integrated properly.

The code changes are approved.


Line range hint 254-274: LGTM!

The function is correctly implemented with the new parameter and function call integrated properly.

The code changes are approved.

Comment on lines +22 to +30
def validate_failing_export(is_auto_export: bool, interval_hours: int, error: Error):
"""
Validate failing export
:param is_auto_export: Is auto export
:param interval_hours: Interval hours
:param error: Error
"""
# If auto export is enabled and interval hours is set and error repetition count is greater than 100, export only once a day
return is_auto_export and interval_hours and error and error.repetition_count > 100 and datetime.now().replace(tzinfo=timezone.utc) - error.updated_at <= timedelta(hours=24)
Copy link

Choose a reason for hiding this comment

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

Reminder: Add unit tests for validate_failing_export.

The function is correctly implemented but lacks unit tests. Ensure to add unit tests to validate its behavior.

Do you want me to generate the unit testing code or open a GitHub issue to track this task?

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 4543e76 and 71f7129.

Files selected for processing (1)
  • tests/test_quickbooks_online/test_tasks.py (6 hunks)
Additional comments not posted (10)
tests/test_quickbooks_online/test_tasks.py (10)

1031-1031: Verify the additional parameter in the function call.

Ensure that the additional parameter 1 aligns with the expected function signature and behavior of schedule_credit_card_purchase_creation.

The code changes are approved, but verification is needed to ensure correctness.


1048-1048: Verify the additional parameter in the function call.

Ensure that the additional parameter 1 aligns with the expected function signature and behavior of schedule_bills_creation.

The code changes are approved, but verification is needed to ensure correctness.


1065-1065: Verify the additional parameter in the function call.

Ensure that the additional parameter 1 aligns with the expected function signature and behavior of schedule_cheques_creation.

The code changes are approved, but verification is needed to ensure correctness.


1082-1082: Verify the additional parameter in the function call.

Ensure that the additional parameter 1 aligns with the expected function signature and behavior of schedule_qbo_expense_creation.

The code changes are approved, but verification is needed to ensure correctness.


1099-1099: Verify the additional parameter in the function call.

Ensure that the additional parameter 1 aligns with the expected function signature and behavior of schedule_journal_entry_creation.

The code changes are approved, but verification is needed to ensure correctness.


1136-1136: Verify the additional parameter in the function call.

Ensure that the additional parameter 1 aligns with the expected function signature and behavior of schedule_bills_creation.

The code changes are approved, but verification is needed to ensure correctness.


1173-1173: Verify the additional parameter in the function call.

Ensure that the additional parameter 1 aligns with the expected function signature and behavior of schedule_journal_entry_creation.

The code changes are approved, but verification is needed to ensure correctness.


1209-1209: Verify the additional parameter in the function call.

Ensure that the additional parameter 1 aligns with the expected function signature and behavior of schedule_qbo_expense_creation.

The code changes are approved, but verification is needed to ensure correctness.


1249-1249: Verify the additional parameter in the function call.

Ensure that the additional parameter 1 aligns with the expected function signature and behavior of schedule_credit_card_purchase_creation.

The code changes are approved, but verification is needed to ensure correctness.


1285-1285: Verify the additional parameter in the function call.

Ensure that the additional parameter 1 aligns with the expected function signature and behavior of schedule_cheques_creation.

The code changes are approved, but verification is needed to ensure correctness.

Copy link

Tests Skipped Failures Errors Time
254 0 💤 0 ❌ 0 🔥 56.787s ⏱️

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 71f7129 and f8dc902.

Files selected for processing (1)
  • tests/test_quickbooks_online/test_tasks.py (6 hunks)
Additional comments not posted (7)
tests/test_quickbooks_online/test_tasks.py (7)

1031-1031: Verify the correctness of the additional parameter.

Ensure that the additional parameter 1 is correctly used in the function call to schedule_credit_card_purchase_creation.


1048-1048: Verify the correctness of the additional parameter.

Ensure that the additional parameter 1 is correctly used in the function call to schedule_bills_creation.


1065-1065: Verify the correctness of the additional parameter.

Ensure that the additional parameter 1 is correctly used in the function call to schedule_cheques_creation.


1082-1082: Verify the correctness of the additional parameter.

Ensure that the additional parameter 1 is correctly used in the function call to schedule_qbo_expense_creation.


1099-1099: Verify the correctness of the additional parameter.

Ensure that the additional parameter 1 is correctly used in the function call to schedule_journal_entry_creation.


1128-1128: Verify the correctness of the additional parameter.

Ensure that the additional parameter 1 is correctly used in the function call to schedule_bills_creation.


1164-1164: Verify the correctness of the additional parameter.

Ensure that the additional parameter 1 is correctly used in the function call to schedule_journal_entry_creation.

@Ashutosh619-sudo Ashutosh619-sudo merged commit a83a2c1 into master Aug 29, 2024
1 check passed
Ashutosh619-sudo added a commit that referenced this pull request Aug 29, 2024
* Max retry for exports

* proper tests

* remove loggers

* remove loggers

* flake resolved
@Hrishabh17 Hrishabh17 added the deploy Triggers deployment of active branch to Staging label Sep 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
deploy Triggers deployment of active branch to Staging
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants