diff --git a/omero_search_engine/api/v1/resources/query_handler.py b/omero_search_engine/api/v1/resources/query_handler.py index 2a51f0b..4792561 100644 --- a/omero_search_engine/api/v1/resources/query_handler.py +++ b/omero_search_engine/api/v1/resources/query_handler.py @@ -408,9 +408,12 @@ def run_query(self, query_, resource): # main_attributes,return_containers=self.return_containers) global res_and_main_attributes, res_or_main_attributes if res_and_main_attributes: - main_attributes["and_main_attributes"] = ( - main_attributes.get("and_main_attributes") + res_and_main_attributes - ) + if main_attributes.get("and_main_attributes"): + main_attributes["and_main_attributes"] = ( + main_attributes.get("and_main_attributes") + res_and_main_attributes + ) + else: + main_attributes["and_main_attributes"] = res_and_main_attributes if resource == "image" and self.return_containers: res = search_query( query, diff --git a/omero_search_engine/validation/results_validator.py b/omero_search_engine/validation/results_validator.py index 8bfc5f2..eb3c5ac 100644 --- a/omero_search_engine/validation/results_validator.py +++ b/omero_search_engine/validation/results_validator.py @@ -872,51 +872,54 @@ def test_no_images(): def get_omero_stats(): - values = ["Attribute", "No. buckets", "Total number", "Resource"] - base_folder = search_omero_app.config.get("BASE_FOLDER") - if not os.path.isdir(base_folder): - base_folder = os.path.expanduser("~") - stats_file = os.path.join(base_folder, "stats.csv") - - from omero_search_engine.api.v1.resources.resource_analyser import ( - get_restircted_search_terms, - query_cashed_bucket, - ) + for data_source in search_omero_app.config.database_connectors.keys(): + values = ["Attribute", "No. buckets", "Total number", "Resource", "Data Source"] + base_folder = search_omero_app.config.get("BASE_FOLDER") + if not os.path.isdir(base_folder): + base_folder = os.path.expanduser("~") + stats_file = os.path.join(base_folder, "stats.csv") + + from omero_search_engine.api.v1.resources.resource_analyser import ( + get_restircted_search_terms, + query_cashed_bucket, + ) - data = [] - terms = get_restircted_search_terms() - data.append(",".join(values)) - for resource, names in terms.items(): - for name in names: - if name == "name": - continue - returned_results = query_cashed_bucket(name, resource) - if resource == "image": - data.append( - "%s, %s, %s,%s" - % ( - name, - returned_results.get("total_number_of_buckets"), - returned_results.get("total_number_of_image"), - resource, + data = [] + terms = get_restircted_search_terms() + data.append(",".join(values)) + for resource, names in terms.items(): + for name in names: + if name == "name": + continue + returned_results = query_cashed_bucket(name, resource, [data_source]) + if resource == "image": + data.append( + "%s, %s, %s,%s,%s" + % ( + name, + returned_results.get("total_number_of_buckets"), + returned_results.get("total_number_of_image"), + resource, + data_source, + ) ) - ) - else: - kk = "total_number_of_%s" % resource - data.append( - "%s, %s, %s,%s" - % ( - name, - returned_results.get("total_number_of_buckets"), - returned_results.get(kk), - resource, + else: + kk = "total_number_of_%s" % resource + data.append( + "%s, %s, %s,%s,%s" + % ( + name, + returned_results.get("total_number_of_buckets"), + returned_results.get(kk), + resource, + data_source, + ) ) - ) - for dat in returned_results.get("data"): - if not dat["Value"]: - print("Value is empty string", dat["Key"]) - report = "\n".join(data) + for dat in returned_results.get("data"): + if not dat["Value"]: + print("Value is empty string", dat["Key"]) + report = "\n".join(data) with open(stats_file, "w") as f: f.write(report)