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:
parent
229823f93e
commit
f9a83705e1
@ -113,6 +113,48 @@ class Services(object):
|
||||
res[cat]["docs"].append(res_doc)
|
||||
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):
|
||||
"""List services matching category
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user