fix(api): fixes perf on charts and introduces sorting by database on datasets (#10392)

This commit is contained in:
Daniel Vaz Gaspar 2020-07-23 19:19:05 +01:00 committed by GitHub
parent e0264060c3
commit 2fd37b18e3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 10 additions and 12 deletions

View File

@ -54,7 +54,10 @@ type Dataset = {
changed_by_url: string; changed_by_url: string;
changed_by: string; changed_by: string;
changed_on_delta_humanized: string; changed_on_delta_humanized: string;
database_name: string; database: {
id: string;
database_name: string;
};
explore_url: string; explore_url: string;
id: number; id: number;
owners: Array<Owner>; owners: Array<Owner>;
@ -275,8 +278,7 @@ const DatasetList: FunctionComponent<DatasetListProps> = ({
}, },
{ {
Header: t('Source'), Header: t('Source'),
accessor: 'database_name', accessor: 'database.database_name',
disableSortBy: true,
size: 'lg', size: 'lg',
}, },
{ {

View File

@ -493,10 +493,6 @@ class SqlaTable( # pylint: disable=too-many-public-methods,too-many-instance-at
def datasource_name(self) -> str: def datasource_name(self) -> str:
return self.table_name return self.table_name
@property
def database_name(self) -> str:
return self.database.name
@classmethod @classmethod
def get_datasource_by_name( def get_datasource_by_name(
cls, cls,

View File

@ -72,8 +72,8 @@ class DatasetRestApi(BaseSupersetModelRestApi):
} }
list_columns = [ list_columns = [
"id", "id",
"database_id", "database.id",
"database_name", "database.database_name",
"changed_by_name", "changed_by_name",
"changed_by_url", "changed_by_url",
"changed_by.first_name", "changed_by.first_name",
@ -97,6 +97,7 @@ class DatasetRestApi(BaseSupersetModelRestApi):
"schema", "schema",
"changed_by.first_name", "changed_by.first_name",
"changed_on_delta_humanized", "changed_on_delta_humanized",
"database.database_name",
] ]
show_columns = [ show_columns = [
"database.database_name", "database.database_name",

View File

@ -269,7 +269,7 @@ class Slice(
@property @property
def changed_by_url(self) -> str: def changed_by_url(self) -> str:
return f"/superset/profile/{self.created_by.username}" # type: ignore return f"/superset/profile/{self.changed_by.username}" # type: ignore
@property @property
def icons(self) -> str: def icons(self) -> str:

View File

@ -92,8 +92,7 @@ class TestDatasetApi(SupersetTestCase):
"changed_by_url", "changed_by_url",
"changed_on_delta_humanized", "changed_on_delta_humanized",
"changed_on_utc", "changed_on_utc",
"database_id", "database",
"database_name",
"default_endpoint", "default_endpoint",
"explore_url", "explore_url",
"id", "id",