on filter update category child relation is deleted as per diff
@@ -53,7 +53,7 @@ async def create_filter(request):
"""
try:
- # Get inpout data
+ # Get input data
data = await request.json()
# Get filter name
filter_name = data.get('name', None)
@@ -127,6 +127,7 @@ async def create_filter(request):
_LOGGER.exception("Add filter, caught exception: " + str(ex))
raise web.HTTPInternalServerError(reason=str(ex))
+
async def add_filters_pipeline(request):
"""
Add filter names to "filter" item in {service_name}
@@ -234,6 +235,17 @@ async def add_filters_pipeline(request):
# Overwriting the list: use input list
new_list = filter_list
+ filter_value_from_storage = json.loads(category_info['filter']['value'])
+
+ def diff(lst1, lst2):
+ return [v for v in lst2 if v not in lst1]
+
+ # Difference b/w two(pipeline and value from storage) lists and then delete relationship as per diff
+ delete_children = diff(new_list, filter_value_from_storage['pipeline'])
+ if delete_children:
+ for l in delete_children:
+ await cf_mgr.delete_child_category(service_name, l)
+
# Set the pipeline value with the 'new_list' of filters
await cf_mgr.set_category_item_value_entry(service_name,
config_item,
