Added function for search listing

Reviewed-by: tischrei <tino.schreiber@t-systems.com>
Co-authored-by: Gode, Sebastian <sebastian.gode@t-systems.com>
Co-committed-by: Gode, Sebastian <sebastian.gode@t-systems.com>
This commit is contained in:
Gode, Sebastian 2023-06-13 08:15:04 +00:00 committed by zuul
parent 229823f93e
commit f9a83705e1

View File

@ -113,6 +113,48 @@ class Services(object):
res[cat]["docs"].append(res_doc) res[cat]["docs"].append(res_doc)
return res return res
def service_types_with_doc_types(self, environment=None):
"""Retrieve type and title from services and corresponding docs.
As well as a list of all doc_types.
:param str environment: Optional service environment.
"""
service_list = []
doc_types = []
for service in self.all_services:
if not service["service_title"]:
continue
if not service["service_type"]:
continue
doc_list = []
for doc in self.all_docs:
if "environment" in doc:
if doc["environment"] != environment:
continue
if doc["service_type"] == service["service_type"]:
doc_list.append({
"title": doc["title"],
"type": doc["type"]
})
if doc["type"] not in doc_types:
doc_types.append(doc["type"])
service_list.append({
"service_title": service["service_title"],
"service_type": service["service_type"],
"docs": doc_list
})
res = {
"services": service_list,
"doc_types": doc_types
}
return res
def docs_by_service_category(self, category, environment=None): def docs_by_service_category(self, category, environment=None):
"""List services matching category """List services matching category