fix: remove keys in dashboard export (#12115)

This commit is contained in:
Beto Dealmeida 2020-12-18 07:54:11 -08:00 committed by GitHub
parent 1a5f61b133
commit 4ae21bf30b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 5 deletions

View File

@ -20,7 +20,7 @@ import json
import logging
import random
import string
from typing import Any, Dict, Iterator, List, Tuple
from typing import Any, Dict, Iterator, List, Optional, Tuple
import yaml
from werkzeug.utils import secure_filename
@ -108,8 +108,8 @@ class ExportDashboardsCommand(ExportModelsCommand):
# TODO (betodealmeida): move this logic to export_to_dict once this
# becomes the default export endpoint
for key, new_name in JSON_KEYS.items():
if payload.get(key):
value = payload.pop(key)
value: Optional[str] = payload.pop(key, None)
if value:
try:
payload[new_name] = json.loads(value)
except (TypeError, json.decoder.JSONDecodeError):

View File

@ -54,7 +54,7 @@ def update_id_refs(config: Dict[str, Any], chart_ids: Dict[str, int]) -> Dict[st
id_map = {old_id: chart_ids[uuid] for uuid, old_id in old_ids.items()}
# fix metadata
metadata = fixed["metadata"]
metadata = fixed.get("metadata", {})
if "timed_refresh_immune_slices" in metadata:
metadata["timed_refresh_immune_slices"] = [
id_map[old_id] for old_id in metadata["timed_refresh_immune_slices"]
@ -82,7 +82,7 @@ def update_id_refs(config: Dict[str, Any], chart_ids: Dict[str, int]) -> Dict[st
}
# fix position
position = fixed["position"]
position = fixed.get("position", {})
for child in position.values():
if (
isinstance(child, dict)