Skip to content

Commit

Permalink
Merge branch 'refresh_employees' into configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
Ashutosh619-sudo committed Jan 2, 2024
2 parents abeb483 + b1935ea commit 6b7e151
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 6 deletions.
6 changes: 4 additions & 2 deletions apps/bamboohr/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@
from fyle_employee_imports.bamboo_hr import BambooHrEmployeeImport
from apps.users.models import User

def refresh_employees(org_id, user):

def refresh_employees(org_id: int, user: User):
"""
Sync Employees from BambooHR to Fyle
"""
bambooHrImporter = BambooHrEmployeeImport(org_id=org_id, user=user)
bambooHrImporter.sync_employees()

Expand Down
2 changes: 1 addition & 1 deletion apps/bamboohr/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ class SyncEmployeesView(generics.UpdateAPIView):

def post(self, request, *args, **kwargs):

async_task('apps.bamboohr.tasks.refresh_employees')
async_task('apps.bamboohr.tasks.refresh_employees', kwargs['org_id'], self.request.user)

return Response(
data = {'message': 'success'},
Expand Down
3 changes: 1 addition & 2 deletions fyle_employee_imports/bamboo_hr.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ class BambooHrEmployeeImport(FyleEmployeeImport):

def __init__(self, org_id: int, user: User):
super().__init__(org_id, user)
bamboo_hr = BambooHr.objects.get(org_id__in=org_id)
self.bamboohr_sdk = BambooHrSDK(api_token=bamboo_hr.api_token, sub_domain=bamboo_hr.sub_domain)
self.bamboohr_sdk = BambooHrSDK(api_token=self.bamboohr.api_token, sub_domain=self.bamboohr.sub_domain)

def sync_hrms_employees(self):
employees = self.bamboohr_sdk.employees.get_all()
Expand Down
2 changes: 1 addition & 1 deletion fyle_employee_imports/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class FyleEmployeeImport():
def __init__(self, org_id: int, user):
self.org_id = org_id
self.user = user
self.bamboohr = BambooHr.objects.get(org_id__in=self.org_id)
self.bamboohr = BambooHr.objects.get(org_id__in=[self.org_id])
refresh_token = AuthToken.objects.get(user__user_id=self.user).refresh_token
cluster_domain = Org.objects.get(user__user_id=self.user).cluster_domain
self.platform_connection = PlatformConnector(refresh_token, cluster_domain)
Expand Down

0 comments on commit 6b7e151

Please sign in to comment.