You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by ma...@apache.org on 2019/07/18 05:23:10 UTC

[incubator-superset] branch master updated: Sort dashboards exported json (#7883)

This is an automated email from the ASF dual-hosted git repository.

maximebeauchemin pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-superset.git


The following commit(s) were added to refs/heads/master by this push:
     new 174a48a  Sort dashboards exported json (#7883)
174a48a is described below

commit 174a48ab554139cc4862205ed26a4e469a274408
Author: Maxim Sukharev <ma...@smacker.ru>
AuthorDate: Thu Jul 18 07:23:04 2019 +0200

    Sort dashboards exported json (#7883)
    
    It makes easier to review changes in dashboards and use git diff
---
 superset/utils/core.py | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/superset/utils/core.py b/superset/utils/core.py
index b0ca2dc..8f0de13 100644
--- a/superset/utils/core.py
+++ b/superset/utils/core.py
@@ -280,6 +280,10 @@ def decode_dashboards(o):
 
 
 class DashboardEncoder(json.JSONEncoder):
+    def __init__(self, *args, **kwargs):
+        super().__init__(*args, **kwargs)
+        self.sort_keys = True
+
     # pylint: disable=E0202
     def default(self, o):
         try:
@@ -288,7 +292,7 @@ class DashboardEncoder(json.JSONEncoder):
         except Exception:
             if type(o) == datetime:
                 return {"__datetime__": o.replace(microsecond=0).isoformat()}
-            return json.JSONEncoder.default(self, o)
+            return json.JSONEncoder(sort_keys=True).default(self, o)
 
 
 def parse_human_timedelta(s: str) -> timedelta: