From 3944152bb8b55a3bc7f3c2af99e28ffe202e97e1 Mon Sep 17 00:00:00 2001 From: Matteo Lodi <30625432+mlodic@users.noreply.github.com> Date: Wed, 29 Nov 2023 15:07:04 +0100 Subject: [PATCH 1/3] adjusting logs --- certego_saas/ext/upload/elastic.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/certego_saas/ext/upload/elastic.py b/certego_saas/ext/upload/elastic.py index 2a84969..f1e3ae8 100644 --- a/certego_saas/ext/upload/elastic.py +++ b/certego_saas/ext/upload/elastic.py @@ -48,14 +48,13 @@ def upload( docs = qs.order_by("+creation_date") if max_number: docs = docs[:max_number] - num_docs = docs.count() - logger.info(f"Uploading {num_docs} documents") + logger.info(f"Uploading {docs.count()} documents") jsons = map(lambda x: x.to_bulk(), docs) success, errors = bulk(client, jsons, request_timeout=timeout) - logger.info(f"Finished Upload. Deleting {num_docs} documents") + logger.info("Finished Upload. Starting deletion documents") for doc in docs.iterator(): doc.delete() - logger.info(f"Finished deleting {num_docs} documents") + logger.info("Finished deleting documents") return success, errors def clean(self): From ae3cc230d56d313042a0455447b22159b30cd819 Mon Sep 17 00:00:00 2001 From: Matteo Lodi <30625432+mlodic@users.noreply.github.com> Date: Thu, 30 Nov 2023 16:12:50 +0100 Subject: [PATCH 2/3] adjusting bi upload (#64) --- certego_saas/ext/upload/__init__.py | 1 + certego_saas/ext/upload/elastic.py | 7 +++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/certego_saas/ext/upload/__init__.py b/certego_saas/ext/upload/__init__.py index 261e576..d0f828d 100644 --- a/certego_saas/ext/upload/__init__.py +++ b/certego_saas/ext/upload/__init__.py @@ -1,3 +1,4 @@ # flake8: noqa +from .elastic import BIDocument, __BIDocumentInterface from .slack import Slack from .twitter import Twitter diff --git a/certego_saas/ext/upload/elastic.py b/certego_saas/ext/upload/elastic.py index f1e3ae8..769d8d0 100644 --- a/certego_saas/ext/upload/elastic.py +++ b/certego_saas/ext/upload/elastic.py @@ -47,13 +47,16 @@ def upload( qs.filter(index=index) docs = qs.order_by("+creation_date") if max_number: + if max_number > 10000: + return False, [ + "max_number can't be higher than 10000 for performance reasons." + ] docs = docs[:max_number] logger.info(f"Uploading {docs.count()} documents") jsons = map(lambda x: x.to_bulk(), docs) success, errors = bulk(client, jsons, request_timeout=timeout) logger.info("Finished Upload. Starting deletion documents") - for doc in docs.iterator(): - doc.delete() + docs.delete() logger.info("Finished deleting documents") return success, errors From fb9981495420eda783e40ef7fabcce1734c3eba4 Mon Sep 17 00:00:00 2001 From: Matteo Lodi <30625432+mlodic@users.noreply.github.com> Date: Thu, 30 Nov 2023 16:13:21 +0100 Subject: [PATCH 3/3] bump 0.7.8 --- certego_saas/version.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/certego_saas/version.py b/certego_saas/version.py index 3591d01..07110a5 100644 --- a/certego_saas/version.py +++ b/certego_saas/version.py @@ -1 +1 @@ -VERSION = "0.7.7" +VERSION = "0.7.8"