def create_jobs_for_calendars()

in ees_microsoft_teams/deletion_command.py [0:0]


    def create_jobs_for_calendars(self, start_time, end_time, queue):
        """Creates jobs for deleting the calendar events
        :param start_time: Start time for fetching the data
        :param end_time: End time for fetching the data
        :param queue: Shared queue for storing the data
        """
        if "calendar" not in self.config.get_value("object_type_to_index"):
            return

        self.logger.debug("Started deleting the calendar events from Microsoft Teams...")
        storage_with_collection = self.local_storage.get_documents_from_doc_id_storage("calendar")
        try:
            calendar_object = self.microsoft_calendar_object(self.get_access_token(is_acquire_for_client=True))
            _, documents = calendar_object.get_calendars(ids_list=[], start_time=start_time, end_time=end_time)

            deleted_data = storage_with_collection.get("delete_keys") or []
            global_keys_documents = storage_with_collection.get("global_keys") or []

            delete_keys_documents = []
            self.remove_deleted_documents_from_global_keys(
                documents, deleted_data, delete_keys_documents, global_keys_documents, "", ""
            )
            queue.append_to_queue("deletion", list(delete_keys_documents))
            storage_with_collection["global_keys"] = list(global_keys_documents)
            storage_with_collection["delete_keys"] = []
            self.local_storage.update_storage(storage_with_collection, "calendar")

        except Exception as exception:
            self.logger.exception(f"Error while deleting the calendars. Error: {exception}")
        self.logger.info("Completed deleting the calendar events from Microsoft Teams")