def perform_sync()

in ees_microsoft_teams/sync_enterprise_search.py [0:0]


    def perform_sync(self):
        """Pull documents from the queue and synchronize it to the Enterprise Search."""
        signal_open = True
        while signal_open:
            documents_to_index, deleted_document = [], []
            while (
                    len(documents_to_index) < constant.BATCH_SIZE
                    and len(str(documents_to_index)) < self.max_allowed_bytes
            ):
                documents = self.queue.get()
                if documents.get("type") == "signal_close":
                    signal_open = False
                    break
                elif documents.get("type") == "checkpoint":
                    self.checkpoint_list.append(documents)
                    break
                elif documents.get("type") == "permissions":
                    self.permission_list_to_index.append(documents.get("data"))
                elif documents.get("type") == "deletion":
                    deleted_document.extend(documents.get("data"))
                else:
                    documents_to_index.extend(documents.get("data"))
            if documents_to_index:
                documents_to_index = list(unique_everseen(documents_to_index))
                for chunk in split_documents_into_equal_chunks(
                    documents_to_index, constant.BATCH_SIZE
                ):
                    for documents in split_documents_into_equal_bytes(
                        chunk, self.max_allowed_bytes
                    ):
                        self.index_documents(chunk)
            if deleted_document:
                deleted_document = list(unique_everseen(deleted_document))
                for chunk in split_documents_into_equal_chunks(
                    deleted_document, constant.BATCH_SIZE
                ):
                    self.delete_documents(chunk)
            if not signal_open:
                break