add get_service_with_docs_by_service_type()
All checks were successful
gl/check check status: success (44320ea668c58f6f70db2aa50fdbaa689403ef87)

This commit is contained in:
Tino Schreiber 2023-02-20 13:50:46 +00:00
parent dd76d849f0
commit 44320ea668

View File

@ -209,3 +209,22 @@ class Services(object):
doc_struct[srv["service_category"]].append(srv_res) doc_struct[srv["service_category"]].append(srv_res)
return dict(categories=doc_struct) return dict(categories=doc_struct)
def get_service_with_docs_by_service_type(self, service_type):
"""Retrieve service and service docs by service_type
:param str service_type: Filter by service_type
"""
res = dict()
res["service"] = {}
docs = []
services = self._service_data
for doc in services['documents']:
if doc['service_type'] == service_type:
docs.append(doc)
res['documents'] = docs
for service in services['services']:
if service['service_type'] == service_type:
res['service'] = service
break
return res