Skip to content

Commit

Permalink
expose queries endpoint
Browse files Browse the repository at this point in the history
(cherry picked from commit d23bfa0)

(cherry picked from commit 7fdd3e8)
(cherry picked from commit 914029d)
(cherry picked from commit 0c35cd9)
(cherry picked from commit fe6ea59)
  • Loading branch information
Sheng Hong Tan authored and xtinec committed Feb 20, 2019
1 parent 58a5117 commit ec2568e
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
3 changes: 3 additions & 0 deletions superset/views/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -2657,6 +2657,9 @@ def fetch_datasource_metadata(self):
@has_access_api
@expose('/queries/<last_updated_ms>')
def queries(self, last_updated_ms):
return self.queries_call(last_updated_ms)

def queries_call(self, last_updated_ms):
"""Get the updated queries."""
stats_logger.incr('queries')
if not g.user.get_id():
Expand Down
9 changes: 9 additions & 0 deletions superset/views/lyft.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,5 +69,14 @@ def sql_json(self):
return json_error_response('{}'.format(e))
return self.sql_json_call(request)

@expose('/queries/<last_updated_ms>')
@log_this
def queries(self, last_updated_ms):
try:
self.authorize()
except (UserDontExistException, SupersetException) as e:
return json_error_response('{}'.format(e))
return self.queries_call(last_updated_ms)


appbuilder.add_view_no_menu(Lyft)
1 change: 1 addition & 0 deletions tests/security_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,7 @@ def test_views_are_secured(self):
['Lyft', 'theme'],
['Lyft', 'welcome'],
['Lyft', 'sql_json'],
['Lyft', 'queries'],
]
unsecured_views = []
for view_class in appbuilder.baseviews:
Expand Down

0 comments on commit ec2568e

Please sign in to comment.