mirror of
https://github.com/apache/superset.git
synced 2026-04-19 16:14:52 +00:00
perf: Implement model specific lookups by id to improve performance (#20974)
* Implement model specific lookups by id to improve performance * Address comments e.g. better variable names and test cleanup * commit after cleanup * even better name and test cleanup via rollback Co-authored-by: Bogdan Kyryliuk <bogdankyryliuk@dropbox.com>
This commit is contained in:
@@ -38,7 +38,8 @@ from superset.utils.core import DatasourceType
|
||||
|
||||
def check_dataset_access(dataset_id: int) -> Optional[bool]:
|
||||
if dataset_id:
|
||||
dataset = DatasetDAO.find_by_id(dataset_id)
|
||||
# Access checks below, no need to validate them twice as they can be expensive.
|
||||
dataset = DatasetDAO.find_by_id(dataset_id, skip_base_filter=True)
|
||||
if dataset:
|
||||
can_access_datasource = security_manager.can_access_datasource(dataset)
|
||||
if can_access_datasource:
|
||||
@@ -49,7 +50,8 @@ def check_dataset_access(dataset_id: int) -> Optional[bool]:
|
||||
|
||||
def check_query_access(query_id: int) -> Optional[bool]:
|
||||
if query_id:
|
||||
query = QueryDAO.find_by_id(query_id)
|
||||
# Access checks below, no need to validate them twice as they can be expensive.
|
||||
query = QueryDAO.find_by_id(query_id, skip_base_filter=True)
|
||||
if query:
|
||||
security_manager.raise_for_access(query=query)
|
||||
return True
|
||||
@@ -81,7 +83,8 @@ def check_access(
|
||||
check_datasource_access(datasource_id, datasource_type)
|
||||
if not chart_id:
|
||||
return True
|
||||
chart = ChartDAO.find_by_id(chart_id)
|
||||
# Access checks below, no need to validate them twice as they can be expensive.
|
||||
chart = ChartDAO.find_by_id(chart_id, skip_base_filter=True)
|
||||
if chart:
|
||||
can_access_chart = security_manager.is_owner(
|
||||
chart
|
||||
|
||||
Reference in New Issue
Block a user