in ees_sharepoint/sync_sharepoint.py [0:0]
def fetch_records_from_sharepoint(self, producer, date_ranges, thread_count, ids, collection):
"""Fetches Sites, Lists, List Items and Drive Items from sharepoint.
:param producer: Producer function
:param date_ranges: Partition of time range
:param thread_count: Thread count
:param ids: Content of the local storage
:param collection: SharePoint server Collection name
"""
# Fetch sites
time_range_list = [(date_ranges[num], date_ranges[num + 1]) for num in range(0, thread_count)]
sites = producer(thread_count, self.fetch_and_append_sites_to_queue,
[ids, collection], time_range_list, wait=True)
all_sites = [{f"/sites/{collection}": self.end_time}]
for site in sites:
all_sites.extend(site)
# Fetch lists
partitioned_sites = split_list_into_buckets(all_sites, thread_count)
lists = producer(thread_count, self.fetch_and_append_lists_to_queue, [ids], partitioned_sites, wait=True)
# Fetch list items
lists_details, libraries_details = {}, {}
for result in lists:
lists_details.update(result[0])
libraries_details.update(result[1])
if LIST_ITEMS in self.objects:
list_items = split_documents_into_equal_chunks(lists_details, thread_count)
producer(thread_count, self.fetch_and_append_list_items_to_queue, [ids], list_items, wait=True)
# Fetch library details
if DRIVE_ITEMS in self.objects:
libraries_items = split_documents_into_equal_chunks(libraries_details, thread_count)
producer(thread_count, self.fetch_and_append_drive_items_to_queue, [ids], libraries_items, wait=True)
return ids