From a912773116ba9a072c742244316898754ae4af4a Mon Sep 17 00:00:00 2001 From: Lucas Agra Date: Thu, 4 Mar 2021 19:21:45 -0300 Subject: [PATCH 1/2] fix pagination --- bothub_backend/bothub.py | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/bothub_backend/bothub.py b/bothub_backend/bothub.py index cd6aa12..de2215c 100644 --- a/bothub_backend/bothub.py +++ b/bothub_backend/bothub.py @@ -149,16 +149,25 @@ def request_backend_save_queue_id(self, update_id, repository_authorization, tas return response @print_execution_time - def request_backend_get_examples(self, update_id, repository_authorization=None, intent=""): - url = f"{self.backend}/v2/repository/nlp/authorization/train/get_examples/" - query_params = { - "repository_version": update_id, - "intent": intent - } - headers = { - "Authorization": f"Bearer {repository_authorization}" - } - response = requests.get(url, params=query_params, headers=headers).json() + def request_backend_get_examples(self, + update_id, + use_pagination=False, + page=None, + repository_authorization=None, + intent="", + ): + headers = { + "Authorization": f"Bearer {repository_authorization}" + } + if not use_pagination: + url = f"{self.backend}/v2/repository/nlp/authorization/train/get_examples/" + query_params = { + "repository_version": update_id, + "intent": intent + } + response = requests.get(url, params=query_params, headers=headers).json() + else: + response = requests.get(page, headers=headers).json() return response From f9e0de2a2eccc113164481067d542f4e2c66deae Mon Sep 17 00:00:00 2001 From: Lucas Agra Date: Fri, 5 Mar 2021 11:11:47 -0300 Subject: [PATCH 2/2] fix pagination --- bothub_backend/bothub.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/bothub_backend/bothub.py b/bothub_backend/bothub.py index de2215c..b4dd4f1 100644 --- a/bothub_backend/bothub.py +++ b/bothub_backend/bothub.py @@ -151,7 +151,6 @@ def request_backend_save_queue_id(self, update_id, repository_authorization, tas @print_execution_time def request_backend_get_examples(self, update_id, - use_pagination=False, page=None, repository_authorization=None, intent="", @@ -159,15 +158,15 @@ def request_backend_get_examples(self, headers = { "Authorization": f"Bearer {repository_authorization}" } - if not use_pagination: + if page: + response = requests.get(page, headers=headers).json() + else: url = f"{self.backend}/v2/repository/nlp/authorization/train/get_examples/" query_params = { "repository_version": update_id, "intent": intent } response = requests.get(url, params=query_params, headers=headers).json() - else: - response = requests.get(page, headers=headers).json() return response