-
Notifications
You must be signed in to change notification settings - Fork 0
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
Resource Category: refactored imports #316
Conversation
WalkthroughThe 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
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 as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
apps/mappings/queue.py
Outdated
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), |
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.
we can hard code true here since we know this block is only for category
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.
Review Status
Actionable comments generated: 1
Configuration used: CodeRabbit UI
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 innew_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 theimport_categories
flag from workspace settings. Ensure that theimport_categories
flag is properly set and managed within theWorkspaceGeneralSettings
model to avoid any unintended behavior.apps/mappings/queue.py (1)
- 147-154: The addition of the
import_categories
condition inconstruct_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 thecharts_of_accounts
setting is properly managed and validated to prevent any issues with the import process. Additionally, consider adding error handling for cases whereworkspace_general_settings
orXeroCredentials
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 |
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.
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
* 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]>
Summary by CodeRabbit