{"action":"created","comment":{"url":"https://api.github.com/repos/apache/incubator-superset/pulls/comments/234044127","pull_request_review_id":175601444,"id":234044127,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIzNDA0NDEyNw==","diff_hunk":"@@ -0,0 +1,94 @@\n+\"\"\"empty message\n+\n+Revision ID: 4ce8df208545\n+Revises: 55e910a74826\n+Create Date: 2018-11-12 13:31:07.578090\n+\n+\"\"\"\n+\n+# revision identifiers, used by Alembic.\n+import json\n+\n+from alembic import op\n+from sqlalchemy import (\n+    Column,\n+    Integer,\n+    Text,\n+)\n+from sqlalchemy.ext.declarative import declarative_base\n+\n+from superset import db\n+\n+revision = '4ce8df208545'\n+down_revision = '55e910a74826'\n+\n+Base = declarative_base()\n+\n+\n+class Dashboard(Base):\n+    \"\"\"Declarative class to do query in upgrade\"\"\"\n+    __tablename__ = 'dashboards'\n+    id = Column(Integer, primary_key=True)\n+    json_metadata = Column(Text)\n+\n+\n+def upgrade():\n+    bind = op.get_bind()\n+    session = db.Session(bind=bind)\n+\n+    dashboards = session.query(Dashboard).all()\n+    for i, dashboard in enumerate(dashboards):\n+        print('scanning dashboard ({}/{}) >>>>'.format(i + 1, len(dashboards)))\n+        if dashboard.json_metadata:\n+            json_metadata = json.loads(dashboard.json_metadata)\n+            has_update = False\n+\n+            # default_filters: it may define time_range filter\n+            default_filters = json_metadata.get('default_filters')\n+            if default_filters and default_filters != '{}':\n+                try:\n+                    filters = json.loads(default_filters)\n+                    keys = [key for key, val in filters.items() if\n+                            val.get('__from') or val.get('__to')]\n+                    if len(keys):\n+                        for key in keys:\n+                            val = filters[key]\n+                            val['__time_range'] = '{} : {}'.format(\n+                                val.pop('__from', ''),\n+                                val.pop('__to', ''),\n+                            )\n+                        json_metadata.update(","path":"superset/migrations/versions/4ce8df208545_migrate_time_range_for_default_filters.py","position":null,"original_position":60,"commit_id":"52195967c286366549921ba8a1b7986ba6012e86","original_commit_id":"cdc06581c0c9b561874c8eb5c0f821c8a235603b","user":{"login":"graceguo-supercat","id":27990562,"node_id":"MDQ6VXNlcjI3OTkwNTYy","avatar_url":"https://avatars3.githubusercontent.com/u/27990562?v=4","gravatar_id":"","url":"https://api.github.com/users/graceguo-supercat","html_url":"https://github.com/graceguo-supercat","followers_url":"https://api.github.com/users/graceguo-supercat/followers","following_url":"https://api.github.com/users/graceguo-supercat/following{/other_user}","gists_url":"https://api.github.com/users/graceguo-supercat/gists{/gist_id}","starred_url":"https://api.github.com/users/graceguo-supercat/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/graceguo-supercat/subscriptions","organizations_url":"https://api.github.com/users/graceguo-supercat/orgs","repos_url":"https://api.github.com/users/graceguo-supercat/repos","events_url":"https://api.github.com/users/graceguo-supercat/events{/privacy}","received_events_url":"https://api.github.com/users/graceguo-supercat/received_events","type":"User","site_admin":false},"body":"fixed.","created_at":"2018-11-15T23:18:21Z","updated_at":"2018-11-15T23:18:22Z","html_url":"https://github.com/apache/incubator-superset/pull/6378#discussion_r234044127","pull_request_url":"https://api.github.com/repos/apache/incubator-superset/pulls/6378","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/apache/incubator-superset/pulls/comments/234044127"},"html":{"href":"https://github.com/apache/incubator-superset/pull/6378#discussion_r234044127"},"pull_request":{"href":"https://api.github.com/repos/apache/incubator-superset/pulls/6378"}},"in_reply_to_id":233992704},"pull_request":{"url":"https://api.github.com/repos/apache/incubator-superset/pulls/6378","id":230374990,"node_id":"MDExOlB1bGxSZXF1ZXN0MjMwMzc0OTkw","html_url":"https://github.com/apache/incubator-superset/pull/6378","diff_url":"https://github.com/apache/incubator-superset/pull/6378.diff","patch_url":"https://github.com/apache/incubator-superset/pull/6378.patch","issue_url":"https://api.github.com/repos/apache/incubator-superset/issues/6378","number":6378,"state":"open","locked":false,"title":"[migration]clean up __from and __to in dashboard json_metadata","user":{"login":"graceguo-supercat","id":27990562,"node_id":"MDQ6VXNlcjI3OTkwNTYy","avatar_url":"https://avatars3.githubusercontent.com/u/27990562?v=4","gravatar_id":"","url":"https://api.github.com/users/graceguo-supercat","html_url":"https://github.com/graceguo-supercat","followers_url":"https://api.github.com/users/graceguo-supercat/followers","following_url":"https://api.github.com/users/graceguo-supercat/following{/other_user}","gists_url":"https://api.github.com/users/graceguo-supercat/gists{/gist_id}","starred_url":"https://api.github.com/users/graceguo-supercat/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/graceguo-supercat/subscriptions","organizations_url":"https://api.github.com/users/graceguo-supercat/orgs","repos_url":"https://api.github.com/users/graceguo-supercat/repos","events_url":"https://api.github.com/users/graceguo-supercat/events{/privacy}","received_events_url":"https://api.github.com/users/graceguo-supercat/received_events","type":"User","site_admin":false},"body":"In dashboard Superset allows user save default values for filter slice, and saved in json_metadata. So that when the dashboard is loaded, it will be pre-populated with values for the filters. Superset also allows user set charts that immune from filters. For example:\r\n\r\n`{\"filter_immune_slices\": [], \"timed_refresh_immune_slices\": [], \"filter_immune_slice_fields\": {\"255\": [\"__from\", \"__to\"]}, \"expanded_slices\": {}, \"default_filters\": \"{\\\"254\\\": {\\\"__from\\\": \\\"1 months ago\\\", \\\"dim_country\\\": [\\\"all\\\"]}}\"}`\r\n\r\nafter recently introduced time_range, __from and __to in json_metadata didn't correctly merge with time_range. It introduces extra __from/__to parameter into Filter control, and cause chart show `no data`. In airbnb we have about 500 dashboards set __from and __to in json_metadata. \r\n\r\n<img width=\"356\" alt=\"screen shot 2018-11-15 at 10 42 32 am\" src=\"https://user-images.githubusercontent.com/27990562/48574153-46ddae00-e8c3-11e8-972c-3d6a451d54ee.png\">\r\n\r\nFix: I wrote this migration script to update __from/__to to __time_range for json_metadata.\r\n\r\n@betodealmeida @mistercrunch @john-bodley @timifasubaa @michellethomas ","created_at":"2018-11-13T07:38:51Z","updated_at":"2018-11-15T23:18:22Z","closed_at":null,"merged_at":null,"merge_commit_sha":"28c59ae3c80aeff4a1d438eb3afb052cd4903573","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[{"id":1127990345,"node_id":"MDU6TGFiZWwxMTI3OTkwMzQ1","url":"https://api.github.com/repos/apache/incubator-superset/labels/db_migration","name":"db_migration","color":"b60205","default":false},{"id":1126422885,"node_id":"MDU6TGFiZWwxMTI2NDIyODg1","url":"https://api.github.com/repos/apache/incubator-superset/labels/target:0.29","name":"target:0.29","color":"c7dbfc","default":false}],"milestone":null,"commits_url":"https://api.github.com/repos/apache/incubator-superset/pulls/6378/commits","review_comments_url":"https://api.github.com/repos/apache/incubator-superset/pulls/6378/comments","review_comment_url":"https://api.github.com/repos/apache/incubator-superset/pulls/comments{/number}","comments_url":"https://api.github.com/repos/apache/incubator-superset/issues/6378/comments","statuses_url":"https://api.github.com/repos/apache/incubator-superset/statuses/52195967c286366549921ba8a1b7986ba6012e86","head":{"label":"graceguo-supercat:gg-MigrateDashboardMetadata","ref":"gg-MigrateDashboardMetadata","sha":"52195967c286366549921ba8a1b7986ba6012e86","user":{"login":"graceguo-supercat","id":27990562,"node_id":"MDQ6VXNlcjI3OTkwNTYy","avatar_url":"https://avatars3.githubusercontent.com/u/27990562?v=4","gravatar_id":"","url":"https://api.github.com/users/graceguo-supercat","html_url":"https://github.com/graceguo-supercat","followers_url":"https://api.github.com/users/graceguo-supercat/followers","following_url":"https://api.github.com/users/graceguo-supercat/following{/other_user}","gists_url":"https://api.github.com/users/graceguo-supercat/gists{/gist_id}","starred_url":"https://api.github.com/users/graceguo-supercat/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/graceguo-supercat/subscriptions","organizations_url":"https://api.github.com/users/graceguo-supercat/orgs","repos_url":"https://api.github.com/users/graceguo-supercat/repos","events_url":"https://api.github.com/users/graceguo-supercat/events{/privacy}","received_events_url":"https://api.github.com/users/graceguo-supercat/received_events","type":"User","site_admin":false},"repo":{"id":92084173,"node_id":"MDEwOlJlcG9zaXRvcnk5MjA4NDE3Mw==","name":"superset","full_name":"graceguo-supercat/superset","private":false,"owner":{"login":"graceguo-supercat","id":27990562,"node_id":"MDQ6VXNlcjI3OTkwNTYy","avatar_url":"https://avatars3.githubusercontent.com/u/27990562?v=4","gravatar_id":"","url":"https://api.github.com/users/graceguo-supercat","html_url":"https://github.com/graceguo-supercat","followers_url":"https://api.github.com/users/graceguo-supercat/followers","following_url":"https://api.github.com/users/graceguo-supercat/following{/other_user}","gists_url":"https://api.github.com/users/graceguo-supercat/gists{/gist_id}","starred_url":"https://api.github.com/users/graceguo-supercat/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/graceguo-supercat/subscriptions","organizations_url":"https://api.github.com/users/graceguo-supercat/orgs","repos_url":"https://api.github.com/users/graceguo-supercat/repos","events_url":"https://api.github.com/users/graceguo-supercat/events{/privacy}","received_events_url":"https://api.github.com/users/graceguo-supercat/received_events","type":"User","site_admin":false},"html_url":"https://github.com/graceguo-supercat/superset","description":"Superset is a modern, enterprise-ready business intelligence web application","fork":true,"url":"https://api.github.com/repos/graceguo-supercat/superset","forks_url":"https://api.github.com/repos/graceguo-supercat/superset/forks","keys_url":"https://api.github.com/repos/graceguo-supercat/superset/keys{/key_id}","collaborators_url":"https://api.github.com/repos/graceguo-supercat/superset/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/graceguo-supercat/superset/teams","hooks_url":"https://api.github.com/repos/graceguo-supercat/superset/hooks","issue_events_url":"https://api.github.com/repos/graceguo-supercat/superset/issues/events{/number}","events_url":"https://api.github.com/repos/graceguo-supercat/superset/events","assignees_url":"https://api.github.com/repos/graceguo-supercat/superset/assignees{/user}","branches_url":"https://api.github.com/repos/graceguo-supercat/superset/branches{/branch}","tags_url":"https://api.github.com/repos/graceguo-supercat/superset/tags","blobs_url":"https://api.github.com/repos/graceguo-supercat/superset/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/graceguo-supercat/superset/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/graceguo-supercat/superset/git/refs{/sha}","trees_url":"https://api.github.com/repos/graceguo-supercat/superset/git/trees{/sha}","statuses_url":"https://api.github.com/repos/graceguo-supercat/superset/statuses/{sha}","languages_url":"https://api.github.com/repos/graceguo-supercat/superset/languages","stargazers_url":"https://api.github.com/repos/graceguo-supercat/superset/stargazers","contributors_url":"https://api.github.com/repos/graceguo-supercat/superset/contributors","subscribers_url":"https://api.github.com/repos/graceguo-supercat/superset/subscribers","subscription_url":"https://api.github.com/repos/graceguo-supercat/superset/subscription","commits_url":"https://api.github.com/repos/graceguo-supercat/superset/commits{/sha}","git_commits_url":"https://api.github.com/repos/graceguo-supercat/superset/git/commits{/sha}","comments_url":"https://api.github.com/repos/graceguo-supercat/superset/comments{/number}","issue_comment_url":"https://api.github.com/repos/graceguo-supercat/superset/issues/comments{/number}","contents_url":"https://api.github.com/repos/graceguo-supercat/superset/contents/{+path}","compare_url":"https://api.github.com/repos/graceguo-supercat/superset/compare/{base}...{head}","merges_url":"https://api.github.com/repos/graceguo-supercat/superset/merges","archive_url":"https://api.github.com/repos/graceguo-supercat/superset/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/graceguo-supercat/superset/downloads","issues_url":"https://api.github.com/repos/graceguo-supercat/superset/issues{/number}","pulls_url":"https://api.github.com/repos/graceguo-supercat/superset/pulls{/number}","milestones_url":"https://api.github.com/repos/graceguo-supercat/superset/milestones{/number}","notifications_url":"https://api.github.com/repos/graceguo-supercat/superset/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/graceguo-supercat/superset/labels{/name}","releases_url":"https://api.github.com/repos/graceguo-supercat/superset/releases{/id}","deployments_url":"https://api.github.com/repos/graceguo-supercat/superset/deployments","created_at":"2017-05-22T18:09:38Z","updated_at":"2018-10-09T05:00:31Z","pushed_at":"2018-11-15T23:01:38Z","git_url":"git://github.com/graceguo-supercat/superset.git","ssh_url":"git@github.com:graceguo-supercat/superset.git","clone_url":"https://github.com/graceguo-supercat/superset.git","svn_url":"https://github.com/graceguo-supercat/superset","homepage":"","size":96756,"stargazers_count":1,"watchers_count":1,"language":"JavaScript","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0","node_id":"MDc6TGljZW5zZTI="},"forks":0,"open_issues":0,"watchers":1,"default_branch":"master"}},"base":{"label":"apache:master","ref":"master","sha":"c17de3940cd57c30c5518718433ccd27ba9b0c66","user":{"login":"apache","id":47359,"node_id":"MDEyOk9yZ2FuaXphdGlvbjQ3MzU5","avatar_url":"https://avatars0.githubusercontent.com/u/47359?v=4","gravatar_id":"","url":"https://api.github.com/users/apache","html_url":"https://github.com/apache","followers_url":"https://api.github.com/users/apache/followers","following_url":"https://api.github.com/users/apache/following{/other_user}","gists_url":"https://api.github.com/users/apache/gists{/gist_id}","starred_url":"https://api.github.com/users/apache/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/apache/subscriptions","organizations_url":"https://api.github.com/users/apache/orgs","repos_url":"https://api.github.com/users/apache/repos","events_url":"https://api.github.com/users/apache/events{/privacy}","received_events_url":"https://api.github.com/users/apache/received_events","type":"Organization","site_admin":false},"repo":{"id":39464018,"node_id":"MDEwOlJlcG9zaXRvcnkzOTQ2NDAxOA==","name":"incubator-superset","full_name":"apache/incubator-superset","private":false,"owner":{"login":"apache","id":47359,"node_id":"MDEyOk9yZ2FuaXphdGlvbjQ3MzU5","avatar_url":"https://avatars0.githubusercontent.com/u/47359?v=4","gravatar_id":"","url":"https://api.github.com/users/apache","html_url":"https://github.com/apache","followers_url":"https://api.github.com/users/apache/followers","following_url":"https://api.github.com/users/apache/following{/other_user}","gists_url":"https://api.github.com/users/apache/gists{/gist_id}","starred_url":"https://api.github.com/users/apache/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/apache/subscriptions","organizations_url":"https://api.github.com/users/apache/orgs","repos_url":"https://api.github.com/users/apache/repos","events_url":"https://api.github.com/users/apache/events{/privacy}","received_events_url":"https://api.github.com/users/apache/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/apache/incubator-superset","description":"Apache Superset (incubating) is a modern, enterprise-ready business intelligence web application","fork":false,"url":"https://api.github.com/repos/apache/incubator-superset","forks_url":"https://api.github.com/repos/apache/incubator-superset/forks","keys_url":"https://api.github.com/repos/apache/incubator-superset/keys{/key_id}","collaborators_url":"https://api.github.com/repos/apache/incubator-superset/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/apache/incubator-superset/teams","hooks_url":"https://api.github.com/repos/apache/incubator-superset/hooks","issue_events_url":"https://api.github.com/repos/apache/incubator-superset/issues/events{/number}","events_url":"https://api.github.com/repos/apache/incubator-superset/events","assignees_url":"https://api.github.com/repos/apache/incubator-superset/assignees{/user}","branches_url":"https://api.github.com/repos/apache/incubator-superset/branches{/branch}","tags_url":"https://api.github.com/repos/apache/incubator-superset/tags","blobs_url":"https://api.github.com/repos/apache/incubator-superset/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/apache/incubator-superset/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/apache/incubator-superset/git/refs{/sha}","trees_url":"https://api.github.com/repos/apache/incubator-superset/git/trees{/sha}","statuses_url":"https://api.github.com/repos/apache/incubator-superset/statuses/{sha}","languages_url":"https://api.github.com/repos/apache/incubator-superset/languages","stargazers_url":"https://api.github.com/repos/apache/incubator-superset/stargazers","contributors_url":"https://api.github.com/repos/apache/incubator-superset/contributors","subscribers_url":"https://api.github.com/repos/apache/incubator-superset/subscribers","subscription_url":"https://api.github.com/repos/apache/incubator-superset/subscription","commits_url":"https://api.github.com/repos/apache/incubator-superset/commits{/sha}","git_commits_url":"https://api.github.com/repos/apache/incubator-superset/git/commits{/sha}","comments_url":"https://api.github.com/repos/apache/incubator-superset/comments{/number}","issue_comment_url":"https://api.github.com/repos/apache/incubator-superset/issues/comments{/number}","contents_url":"https://api.github.com/repos/apache/incubator-superset/contents/{+path}","compare_url":"https://api.github.com/repos/apache/incubator-superset/compare/{base}...{head}","merges_url":"https://api.github.com/repos/apache/incubator-superset/merges","archive_url":"https://api.github.com/repos/apache/incubator-superset/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/apache/incubator-superset/downloads","issues_url":"https://api.github.com/repos/apache/incubator-superset/issues{/number}","pulls_url":"https://api.github.com/repos/apache/incubator-superset/pulls{/number}","milestones_url":"https://api.github.com/repos/apache/incubator-superset/milestones{/number}","notifications_url":"https://api.github.com/repos/apache/incubator-superset/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/apache/incubator-superset/labels{/name}","releases_url":"https://api.github.com/repos/apache/incubator-superset/releases{/id}","deployments_url":"https://api.github.com/repos/apache/incubator-superset/deployments","created_at":"2015-07-21T18:55:34Z","updated_at":"2018-11-15T21:36:47Z","pushed_at":"2018-11-15T23:01:40Z","git_url":"git://github.com/apache/incubator-superset.git","ssh_url":"git@github.com:apache/incubator-superset.git","clone_url":"https://github.com/apache/incubator-superset.git","svn_url":"https://github.com/apache/incubator-superset","homepage":"","size":95677,"stargazers_count":21829,"watchers_count":21829,"language":"JavaScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":3915,"mirror_url":null,"archived":false,"open_issues_count":1070,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0","node_id":"MDc6TGljZW5zZTI="},"forks":3915,"open_issues":1070,"watchers":21829,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/apache/incubator-superset/pulls/6378"},"html":{"href":"https://github.com/apache/incubator-superset/pull/6378"},"issue":{"href":"https://api.github.com/repos/apache/incubator-superset/issues/6378"},"comments":{"href":"https://api.github.com/repos/apache/incubator-superset/issues/6378/comments"},"review_comments":{"href":"https://api.github.com/repos/apache/incubator-superset/pulls/6378/comments"},"review_comment":{"href":"https://api.github.com/repos/apache/incubator-superset/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/apache/incubator-superset/pulls/6378/commits"},"statuses":{"href":"https://api.github.com/repos/apache/incubator-superset/statuses/52195967c286366549921ba8a1b7986ba6012e86"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"graceguo-supercat"}}