[dashboard] fix filter_scopes when copy dashboard with duplicate_slices (#9188)

* [dashboard] fix filter_scopes when copy dashboard with duplicate_slices

* code cleanup
This commit is contained in:
Grace Guo
2020-02-24 13:45:29 -08:00
committed by GitHub
parent 8c095a6e39
commit 421aeb4605
3 changed files with 38 additions and 16 deletions

View File

@@ -70,3 +70,17 @@ def convert_filter_scopes(json_metadata: Dict, filters: List[Slice]):
filter_scopes[filter_id] = filter_fields
return filter_scopes
def copy_filter_scopes(
old_to_new_slc_id_dict: Dict[int, int], old_filter_scopes: Dict[str, Dict]
) -> Dict:
new_filter_scopes = {}
for (slice_id, scopes) in old_filter_scopes.items():
new_filter_key = old_to_new_slc_id_dict[int(slice_id)]
new_filter_scopes[str(new_filter_key)] = scopes
for scope in scopes.values():
scope["immune"] = [
old_to_new_slc_id_dict[slice_id] for slice_id in scope.get("immune")
]
return new_filter_scopes