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

API view added for refreshing employees from BambooHR #120

Merged
merged 6 commits into from
Jan 3, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions apps/bamboohr/tasks.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from apps.bamboohr.models import BambooHr
from apps.fyle_hrms_mappings.models import DestinationAttribute
from fyle_employee_imports.bamboo_hr import BambooHrEmployeeImport

def refresh_employees(org_id, user):

Copy link
Contributor

Choose a reason for hiding this comment

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

remove empty line, add doc strings, arg type

bambooHrImporter = BambooHrEmployeeImport(org_id=org_id, user=user)
bambooHrImporter.sync_employees()

23 changes: 6 additions & 17 deletions apps/bamboohr/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from apps.bamboohr.actions import disconnect_bamboohr, sync_employees
from apps.names import BAMBOO_HR

from rest_framework.views import APIView
from django_q.tasks import async_task

logger = logging.getLogger(__name__)
logger.level = logging.INFO
Expand Down Expand Up @@ -230,20 +230,9 @@ class SyncEmployeesView(generics.UpdateAPIView):

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

try:
config = BambooHrConfiguration.objects.get(org__id=kwargs['org_id'])
sync_recipe = sync_employees(kwargs['org_id'], config)
async_task('apps.bamboohr.tasks.refresh_employees')

# in case of an error response
if isinstance(sync_recipe, Response):
return sync_recipe

return Response(
data=sync_recipe,
status=status.HTTP_200_OK
)
except BambooHrConfiguration.DoesNotExist:
return Response(
data={'message': 'BambooHr Configuration does not exist for this Workspace'},
status=status.HTTP_404_NOT_FOUND
)
return Response(
data = {'message': 'success'},
status=status.HTTP_201_CREATED
)
Loading