Skip to content

Commit

Permalink
adjusting bi upload
Browse files Browse the repository at this point in the history
  • Loading branch information
mlodic committed Nov 30, 2023
1 parent 3944152 commit 612626d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
1 change: 1 addition & 0 deletions certego_saas/ext/upload/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# flake8: noqa
from .elastic import BIDocument, __BIDocumentInterface
from .slack import Slack
from .twitter import Twitter
7 changes: 5 additions & 2 deletions certego_saas/ext/upload/elastic.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 612626d

Please sign in to comment.