Skip to content

Commit

Permalink
better optimized code
Browse files Browse the repository at this point in the history
  • Loading branch information
Ashutosh619-sudo committed Dec 22, 2023
1 parent 931f04d commit 8d6009f
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions fyle_employee_imports/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,9 @@ def create_fyle_department_payload(self, existing_departments, new_departments):

return departments_payload

def departments_to_be_imported(self):
def departments_to_be_imported(self, hrms_employees):

new_departments = []
hrms_employees = DestinationAttribute.objects.filter(
attribute_type='EMPLOYEE',
org_id=self.org_id
).order_by('value', 'id')

for employee in hrms_employees:
if employee.detail['department_name']:
Expand All @@ -72,9 +68,9 @@ def post_department(self, departments_payload):
for department in departments_payload:
self.platform_connection.post_department(department)

def import_departments(self):
def import_departments(self, hrms_employees):
existing_departments = self.get_existing_departments_from_fyle()
new_departments = self.departments_to_be_imported()
new_departments = self.departments_to_be_imported(hrms_employees)
departments_payload = self.create_fyle_department_payload(existing_departments, new_departments)
self.post_department(departments_payload)

Expand All @@ -91,4 +87,9 @@ def sync_employees(self):
self.sync_fyle_employees()
self.sync_hrms_employees()

self.import_departments()
hrms_employees = DestinationAttribute.objects.filter(
attribute_type='EMPLOYEE',
org_id=self.org_id
).order_by('value', 'id')

self.import_departments(hrms_employees)

0 comments on commit 8d6009f

Please sign in to comment.