From d73a2da3e67371b4575938e27d13f43fe454e9c4 Mon Sep 17 00:00:00 2001 From: Angelina Tingaeva Date: Thu, 14 Dec 2023 14:37:46 +0500 Subject: [PATCH] refactor(resolved_task): make full search --- resolved_task.py | 56 +++++++++++++++++++++++++----------------------- 1 file changed, 29 insertions(+), 27 deletions(-) diff --git a/resolved_task.py b/resolved_task.py index 0d934a1..b67d2a5 100644 --- a/resolved_task.py +++ b/resolved_task.py @@ -37,36 +37,38 @@ def close_tasks_in_queue(queue_name): } } - response = requests.post( - base_url, - headers=headers, - data=json.dumps(payload) - ) + while True: - if response.status_code == 200: - logger.debug('Response: %s', response.content) + response = requests.post( + base_url, + headers=headers, + data=json.dumps(payload) + ) - tasks = response.json() + if response.status_code == 200: + logger.debug('Response: %s', response.content) - for task in tasks: - task_id = task['id'] - close_payload = { - 'resolution': 'fixed' - } - close_url = f'https://api.tracker.yandex.net/v2/issues/{task_id}/transitions/close/_execute' - print(close_url) - print(headers) - close_response = requests.post( - close_url, - headers=headers, - data=json.dumps(close_payload) - ) - if close_response.status_code == 200: - print(f'Задача {task_id} закрыта успешно') - else: - print(f'Ошибка при закрытии задачи {task_id}: {close_response.content}') - else: - print(f'Ошибка при получении задач для очереди {queue_name}: {response.content}') + tasks = response.json() + + for task in tasks: + task_id = task['id'] + close_payload = { + 'resolution': 'fixed' + } + close_url = f'https://api.tracker.yandex.net/v2/issues/{task_id}/transitions/close/_execute' + print(close_url) + print(headers) + close_response = requests.post( + close_url, + headers=headers, + data=json.dumps(close_payload) + ) + if close_response.status_code == 200: + print(f'Задача {task_id} закрыта успешно') + else: + print(f'Ошибка при закрытии задачи {task_id}: {close_response.content}') + else: + print(f'Ошибка при получении задач для очереди {queue_name}: {response.content}') # Вызов функции для закрытия задач в очереди 'TESTIMPORT'