superset-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From maximebeauche...@apache.org
Subject [incubator-superset] branch master updated: Visualization Unicode bug fix (#5387)
Date Thu, 26 Jul 2018 20:18:38 GMT
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 54fba0f  Visualization Unicode bug fix (#5387)
54fba0f is described below

commit 54fba0f39ccc434f0cf9235d88c4a1b3b7d13054
Author: JamshedRahman <31935303+JamshedRahman@users.noreply.github.com>
AuthorDate: Thu Jul 26 13:18:35 2018 -0700

    Visualization Unicode bug fix (#5387)
    
    * Visualization Unicode bug fix
    
    * Fix the build (#5403)
    
    The travis build has been failing for 2 reasons recently
    * pylint takes > 10 minutes without outputing
    * bad merge confict auto resolve in controls.jsx
    
    * Visualization Unicode bug fix
---
 superset/viz.py    |  6 +++---
 tests/viz_tests.py | 36 ++++++++++++++++++++++++++++++++++++
 2 files changed, 39 insertions(+), 3 deletions(-)

diff --git a/superset/viz.py b/superset/viz.py
index d1732fa..59acb9f 100644
--- a/superset/viz.py
+++ b/superset/viz.py
@@ -125,7 +125,7 @@ class BaseViz(object):
                     # if an int is too big for Java Script to handle
                     # convert it to a string
                     if abs(v) > JS_MAX_INTEGER:
-                        d[k] = str(v)
+                        d[k] = text_type(v)
         return data
 
     def run_extra_queries(self):
@@ -770,7 +770,7 @@ class CalHeatmapViz(BaseViz):
         records = df.to_dict('records')
         for metric in self.metric_labels:
             data[metric] = {
-                str(obj[DTTM_ALIAS].value / 10**9): obj.get(metric)
+                text_type(obj[DTTM_ALIAS].value / 10**9): obj.get(metric)
                 for obj in records
             }
 
@@ -1530,7 +1530,7 @@ class DistributionBarViz(DistributionPieViz):
             elif len(metrics) > 1:
                 series_title = ', '.join(name)
             else:
-                l = [str(s) for s in name[1:]]  # noqa: E741
+                l = [text_type(s) for s in name[1:]]  # noqa: E741
                 series_title = ', '.join(l)
             values = []
             for i, v in ys.items():
diff --git a/tests/viz_tests.py b/tests/viz_tests.py
index 0602c0a..95a69fc 100644
--- a/tests/viz_tests.py
+++ b/tests/viz_tests.py
@@ -976,3 +976,39 @@ class BaseDeckGLVizTestCase(unittest.TestCase):
 
         with self.assertRaises(SpatialException):
             test_viz_deckgl.parse_coordinates('fldkjsalkj,fdlaskjfjadlksj')
+
+
+class TimeSeriesVizTestCase(unittest.TestCase):
+
+    def test_timeseries_unicode_data(self):
+        datasource = Mock()
+        form_data = {
+            'groupby': ['name'],
+            'metrics': ['sum__payout'],
+        }
+        raw = {}
+        raw['name'] = [
+            'Real Madrid C.F.πŸ‡ΊπŸ‡ΈπŸ‡¬πŸ‡§', 'Real Madrid C.F.πŸ‡ΊπŸ‡ΈπŸ‡¬πŸ‡§',
+            'Real Madrid Basket', 'Real Madrid Basket',
+        ]
+        raw['__timestamp'] = [
+            '2018-02-20T00:00:00', '2018-03-09T00:00:00',
+            '2018-02-20T00:00:00', '2018-03-09T00:00:00',
+        ]
+        raw['sum__payout'] = [2, 2, 4, 4]
+        df = pd.DataFrame(raw)
+
+        test_viz = viz.NVD3TimeSeriesViz(datasource, form_data)
+        viz_data = {}
+        viz_data = test_viz.get_data(df)
+        expected = [
+            {u'values': [
+                {u'y': 4, u'x': u'2018-02-20T00:00:00'},
+                {u'y': 4, u'x': u'2018-03-09T00:00:00'}],
+                u'key': (u'Real Madrid Basket',)},
+            {u'values': [
+                {u'y': 2, u'x': u'2018-02-20T00:00:00'},
+                {u'y': 2, u'x': u'2018-03-09T00:00:00'}],
+                u'key': (u'Real Madrid C.F.\U0001f1fa\U0001f1f8\U0001f1ec\U0001f1e7',)},
+        ]
+        self.assertEqual(expected, viz_data)


Mime
View raw message