Multiple attempts to change role to compensate Zendesk API delay
This commit is contained in:
parent
045d2cfb2b
commit
a5d0c222bd
@ -48,8 +48,8 @@ def make_light_agent(user_profile: UserProfile, who_changes: User) -> None:
|
||||
:return: Вызов функции **update_role** с параметрами: профиль пользователя, роль "light_agent"
|
||||
"""
|
||||
tickets = get_tickets_list(user_profile.user.email)
|
||||
tickets_to_update = []
|
||||
buffer_group = zenpy.get_group(ZENDESK_GROUPS['buffer'])
|
||||
solved_tickets_user = zenpy.get_user(SOLVED_TICKETS_EMAIL)
|
||||
for ticket in tickets:
|
||||
UnassignedTicket.objects.create(
|
||||
assignee=user_profile.user,
|
||||
@ -57,15 +57,22 @@ def make_light_agent(user_profile: UserProfile, who_changes: User) -> None:
|
||||
status=UnassignedTicketStatus.SOLVED if ticket.status == 'solved' else UnassignedTicketStatus.UNASSIGNED
|
||||
)
|
||||
if ticket.status == 'solved':
|
||||
ticket.assignee = zenpy.get_user(SOLVED_TICKETS_EMAIL)
|
||||
ticket.assignee = solved_tickets_user
|
||||
else:
|
||||
ticket.assignee = None
|
||||
ticket.group = buffer_group
|
||||
tickets_to_update.append(ticket)
|
||||
|
||||
print(tickets_to_update)
|
||||
zenpy.admin.tickets.update(tickets.values)
|
||||
|
||||
attempts, success = 5, False
|
||||
while not success and attempts != 0:
|
||||
try:
|
||||
update_role(user_profile, ROLES['light_agent'])
|
||||
success = True
|
||||
except APIException as e:
|
||||
attempts -= 1
|
||||
if attempts == 0:
|
||||
raise e
|
||||
|
||||
|
||||
def get_users_list() -> list:
|
||||
|
Loading…
x
Reference in New Issue
Block a user