Skip to content

Commit

Permalink
adding items support for scheduling
Browse files Browse the repository at this point in the history
  • Loading branch information
labhvam5 committed Nov 26, 2023
1 parent 7d23a01 commit 88ee3dc
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 8 deletions.
4 changes: 2 additions & 2 deletions apps/mappings/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ def schedule_or_delete_fyle_import_tasks(configuration: WorkspaceGeneralSettings
:param configuration: WorkspaceGeneralSettings Instance
:return: None
"""
if configuration.import_categories or configuration.import_items or configuration.import_vendors_as_merchants:
if configuration.import_vendors_as_merchants:
start_datetime = datetime.now()
Schedule.objects.update_or_create(func='apps.mappings.tasks.auto_import_and_map_fyle_fields', args='{}'.format(configuration.workspace_id), defaults={'schedule_type': Schedule.MINUTES, 'minutes': 24 * 60, 'next_run': start_datetime})
elif not configuration.import_categories and not configuration.import_items and not configuration.import_vendors_as_merchants:
elif not configuration.import_vendors_as_merchants:
Schedule.objects.filter(func='apps.mappings.tasks.auto_import_and_map_fyle_fields', args='{}'.format(configuration.workspace_id)).delete()


Expand Down
4 changes: 2 additions & 2 deletions apps/mappings/schedules.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def schedule_or_delete_fyle_import_tasks(workspace_general_settings: WorkspaceGe
if mapping_setting_instance and mapping_setting_instance.import_to_fyle:
task_to_be_scheduled = mapping_setting_instance

if task_to_be_scheduled or workspace_general_settings.import_categories:
if task_to_be_scheduled or workspace_general_settings.import_categories or workspace_general_settings.import_items:
Schedule.objects.update_or_create(
func='apps.mappings.queues.construct_tasks_and_chain_import_fields_to_fyle',
args='{}'.format(workspace_general_settings.workspace_id),
Expand All @@ -35,7 +35,7 @@ def schedule_or_delete_fyle_import_tasks(workspace_general_settings: WorkspaceGe
).count()

# If the import fields count is 0, delete the schedule
if import_fields_count == 0 and not workspace_general_settings.import_categories:
if import_fields_count == 0 and not workspace_general_settings.import_categories and not workspace_general_settings.import_items:
Schedule.objects.filter(
func='apps.mappings.queues.construct_tasks_and_chain_import_fields_to_fyle',
args='{}'.format(workspace_general_settings.workspace_id)
Expand Down
3 changes: 0 additions & 3 deletions apps/mappings/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -732,8 +732,5 @@ def auto_import_and_map_fyle_fields(workspace_id):
if workspace_general_settings.import_vendors_as_merchants:
chain.append('apps.mappings.tasks.auto_create_vendors_as_merchants', workspace_id)

if workspace_general_settings.import_categories or workspace_general_settings.import_items:
chain.append('apps.mappings.tasks.auto_create_category_mappings', workspace_id)

if chain.length() > 0:
chain.run()
2 changes: 1 addition & 1 deletion fyle_integrations_imports

0 comments on commit 88ee3dc

Please sign in to comment.