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

Resource Category: refactored imports #316

Merged
merged 12 commits into from
Mar 4, 2024

Conversation

Hrishabh17
Copy link
Contributor

@Hrishabh17 Hrishabh17 commented Mar 1, 2024

Summary by CodeRabbit

  • New Features
    • Introduced settings to support importing categories based on workspace general settings.
  • Refactor
    • Streamlined category import functionality by removing unused functions and conditions.

@Hrishabh17 Hrishabh17 requested a review from ashwin1111 March 1, 2024 08:36
Copy link

coderabbitai bot commented Mar 1, 2024

Walkthrough

The recent update introduces a significant enhancement in the application's capability to manage categories, particularly focusing on importing them based on workspace settings. A new condition ensures that categories are imported only if specified in the workspace general settings. This update simplifies the task scheduling related to category import and streamlines the codebase by removing redundant functions related to category management and synchronization.

Changes

File Path Change Summary
.../queue.py Added a condition to include settings for importing categories if workspace_general_settings.import_categories is true.
.../schedules.py Included a condition to manage scheduling for importing categories based on workspace settings.
.../tasks.py Removed several functions related to category management and synchronization.

🐇💻
In the land of code and byte,
Where functions dance and data alight,
A rabbit hopped with glee so bright,
For categories now import just right.
No more clutter, no more plight,
Just seamless syncs in the moonlight.

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-tests for this file.
  • 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 tests 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 tests.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

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 a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @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.
  • The JSON schema for the configuration file is available here.
  • 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/coderabbit-overrides.v2.json

CodeRabbit Discord Community

Join our Discord Community to get help, request features, and share feedback.

task_settings['import_categories'] = {
'destination_field': 'ACCOUNT',
'destination_sync_methods': [SYNC_METHODS['ACCOUNT']],
'is_auto_sync_enabled': is_auto_sync_allowed(workspace_general_settings, None),
Copy link
Contributor

Choose a reason for hiding this comment

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

we can hard code true here since we know this block is only for category

@Hrishabh17 Hrishabh17 changed the base branch from refactor-imports-taxgroup to imports-refactor-master March 4, 2024 15:04
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.

Review Status

Actionable comments generated: 1

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 457537b and c94a7b8.
Files selected for processing (3)
  • apps/mappings/queue.py (1 hunks)
  • apps/mappings/schedules.py (1 hunks)
  • apps/mappings/tasks.py (5 hunks)
Additional comments: 2
apps/mappings/schedules.py (1)
  • 26-26: The addition of workspace_general_settings_instance.import_categories to the logical OR chain in new_schedule_or_delete_fyle_import_tasks function is a logical extension of the existing conditions. This change allows for dynamic scheduling or deletion of Fyle import tasks based on the import_categories flag from workspace settings. Ensure that the import_categories flag is properly set and managed within the WorkspaceGeneralSettings model to avoid any unintended behavior.
apps/mappings/queue.py (1)
  • 147-154: The addition of the import_categories condition in construct_tasks_and_chain_import_fields_to_fyle function with detailed settings for importing categories is a significant enhancement. This change allows for a more customizable and efficient import process based on workspace settings. Ensure that the charts_of_accounts setting is properly managed and validated to prevent any issues with the import process. Additionally, consider adding error handling for cases where workspace_general_settings or XeroCredentials might not be set or accessible, to improve the robustness of the code.

@@ -1,8 +1,8 @@
import logging
from typing import Dict, List
from typing import List
Copy link

Choose a reason for hiding this comment

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

Tip

Codebase Verification

The verification process revealed that while some of the removed functions from tasks.py are not referenced elsewhere in the codebase, several are still referenced in test files and scripts. Specifically, functions like remove_duplicates, create_fyle_categories_payload, get_all_categories_from_fyle, upload_categories_to_fyle, and auto_create_category_mappings are referenced in test files, indicating that the corresponding tests may fail or become irrelevant due to the removal of these functions. Additionally, auto_create_category_mappings is referenced in scripts, suggesting external dependencies or automation processes that could be impacted.

Given these findings, it's crucial to update or remove the affected tests and assess the implications of removing these functions on any external scripts or automation relying on them. This ensures that the codebase remains consistent and functional after the refactor.

Analysis chain

The removal of several functions related to expense attributes and category mapping in tasks.py suggests a significant refactor. It's crucial to ensure that the functionalities provided by these removed functions are either no longer required or have been replaced by more efficient implementations elsewhere in the application. This change could potentially simplify the codebase and improve performance, but careful consideration should be given to any dependencies or features that may be affected.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Verify that the removed functions are not called from anywhere within the codebase.
for func in disable_expense_attributes remove_duplicates create_fyle_categories_payload get_all_categories_from_fyle upload_categories_to_fyle auto_create_category_mappings sync_xero_attributes; do
  echo "Searching for references to $func"
  rg --type py $func
done

Length of output: 4528

@Hrishabh17 Hrishabh17 merged commit 44e9af1 into imports-refactor-master Mar 4, 2024
1 check passed
Hrishabh17 added a commit that referenced this pull request Mar 12, 2024
* Added integrations_imports submodule, made changes in settings (#310)

* Refactor imports for Project resource (#311)

* Added integrations_imports submodule, made changes in settings

* Resource Project: Added new flow for the Project Import

* Typo Fix

* Resource Project: removed old import logic for Project

* Resource Project: added cluster import, fixed minor typo, added new supplier field

* Refactor imports for project and cost_center (#314)

* Added integrations_imports submodule, made changes in settings

* Resource Project: Added new flow for the Project Import

* Typo Fix

* Resource Project: removed old import logic for Project

* Resource Project: added cluster import, fixed minor typo, added new supplier field

* Refactor imports costcenter (#312)

* Resource Cost_Center: refactored imports

* Refactor imports for Project resource (#311)

* Added integrations_imports submodule, made changes in settings

* Resource Project: Added new flow for the Project Import

* Typo Fix

* Resource Project: removed old import logic for Project

* Resource Project: added cluster import, fixed minor typo, added new supplier field

* Refactor imports custom expense (#313)

* Added integrations_imports submodule, made changes in settings

* Resource Project: Added new flow for the Project Import

* Typo Fix

* Resource Project: removed old import logic for Project

* Resource Cost_Center: refactored imports

* Resource Custom Expense Field: refactored imports

* Resource Project: added cluster import, fixed minor typo, added new supplier field

* Resource Tax Group: refactored imports (#315)

* Added integrations_imports submodule, made changes in settings

* Resource Project: Added new flow for the Project Import

* Typo Fix

* Resource Project: removed old import logic for Project

* Resource Cost_Center: refactored imports

* Resource Custom Expense Field: refactored imports

* Resource Project: added cluster import, fixed minor typo, added new supplier field

* Resource Tax Group: refactored imports

* Resource Tax Group: changed to is_auto_sync to False by default

* Resource Category: refactored imports (#316)

* Added integrations_imports submodule, made changes in settings

* Resource Project: Added new flow for the Project Import

* Typo Fix

* Resource Project: removed old import logic for Project

* Resource Cost_Center: refactored imports

* Resource Custom Expense Field: refactored imports

* Resource Tax Group: refactored imports

* Resource Category: refactored imports

* Resource Category: changed is_auto_sync_enabled to True by default

* Refactor imports supplier (#318)

* Added integrations_imports submodule, made changes in settings

* Resource Project: Added new flow for the Project Import

* Typo Fix

* Resource Project: removed old import logic for Project

* Resource Cost_Center: refactored imports

* Resource Custom Expense Field: refactored imports

* Resource Tax Group: refactored imports

* Resource Category: refactored imports

* Added RetryException handler and bumped the sdk versions (#306)

* Set tasks limit to 1L (#317)

* Set tasks limit to 1L

* set timeout

* Modified the import schedule creation condition

---------

Co-authored-by: ruuushhh <[email protected]>

* Refactor old flow (#321)

* Added integrations_imports submodule, made changes in settings

* Resource Project: Added new flow for the Project Import

* Typo Fix

* Resource Project: removed old import logic for Project

* Resource Cost_Center: refactored imports

* Resource Custom Expense Field: refactored imports

* Resource Tax Group: refactored imports

* Resource Category: refactored imports

* Added RetryException handler and bumped the sdk versions (#306)

* Set tasks limit to 1L (#317)

* Set tasks limit to 1L

* set timeout

* Modified the import schedule creation condition

* Removed dead code, add few test cases, added script for adding new schedule for different workspaces

* Added post deploy sql script to dump old schedules and delete

---------

Co-authored-by: ruuushhh <[email protected]>

* Merged changes from master

* Update delete workspace func (#319)

* Update delete workspace func

* Fix comments

* upate workspace last synced fix (#320)

* Modified the workflow for submodule

* Decreased the coverage to 88%

---------

Co-authored-by: ruuushhh <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants