diff --git a/.gitignore b/.gitignore index 6d6cef476da10824272a8c80600560dd9256dd54..58ea41ca1bcaeb84387bb6b0a8d45cfc41c79119 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,4 @@ integration/*.html # Integration logs integration/*.log +*.env \ No newline at end of file diff --git a/ldvspec/lofardata/views.py b/ldvspec/lofardata/views.py index bf226ed4764ac77e46cc162795c912e7c9ccf618..742ccb6ee3cf83f46434342fdec401c2abeeb785 100644 --- a/ldvspec/lofardata/views.py +++ b/ldvspec/lofardata/views.py @@ -151,15 +151,27 @@ def retrieve_general_dataproduct_information(sas_id): "dataproduct_type", "project", "location", - "activity").distinct() - combined_data_products_on_key = {} + "activity", + "additional_meta").distinct() + combined_data_products_on_key = combine_dataproducts_on_key(data_products, {}) + + return combined_data_products_on_key + + +def combine_dataproducts_on_key(data_products, combined_data_products): for data_product in data_products: - for key, value in data_product.items(): - if combined_data_products_on_key.get(key) and value not in combined_data_products_on_key.get(key): - combined_data_products_on_key[key].append(value) - else: - combined_data_products_on_key[key] = [value] + combined_data_products = fill_unique_nested_dict(data_product, combined_data_products) + return combined_data_products + +def fill_unique_nested_dict(data_product, combined_data_products_on_key): + for key, value in data_product.items(): + if isinstance(value, dict): + combined_data_products_on_key = fill_unique_nested_dict(value, combined_data_products_on_key) + elif combined_data_products_on_key.get(key) and value not in combined_data_products_on_key.get(key): + combined_data_products_on_key[key].append(value) + else: + combined_data_products_on_key[key] = [value] return combined_data_products_on_key