diff --git a/backend/dataall/core/environment/db/environment_repositories.py b/backend/dataall/core/environment/db/environment_repositories.py index 352af8ff0..7aca43b40 100644 --- a/backend/dataall/core/environment/db/environment_repositories.py +++ b/backend/dataall/core/environment/db/environment_repositories.py @@ -142,7 +142,7 @@ def query_all_environment_consumption_roles(session, uri, filter) -> Query: ConsumptionRole.groupUri == group, ) ) - return query.order_by(ConsumptionRole.consumptionRoleUri) + return query.order_by(ConsumptionRole.consumptionRoleName) @staticmethod def query_user_environment_consumption_roles(session, groups, uri, filter) -> Query: @@ -166,7 +166,7 @@ def query_user_environment_consumption_roles(session, groups, uri, filter) -> Qu ConsumptionRole.groupUri == group, ) ) - return query.order_by(ConsumptionRole.consumptionRoleUri) + return query.order_by(ConsumptionRole.consumptionRoleName) @staticmethod def query_environment_invited_groups(session, uri, filter) -> Query: @@ -190,7 +190,7 @@ def query_environment_invited_groups(session, uri, filter) -> Query: EnvironmentGroup.groupUri.ilike('%' + term + '%'), ) ) - return query + return query.order_by(EnvironmentGroup.groupUri) @staticmethod def query_user_environment_groups(session, groups, uri, filter) -> Query: @@ -206,7 +206,7 @@ def query_user_environment_groups(session, groups, uri, filter) -> Query: EnvironmentGroup.groupUri.ilike('%' + term + '%'), ) ) - return query + return query.order_by(EnvironmentGroup.groupUri) @staticmethod def query_all_environment_groups(session, uri, filter) -> Query: @@ -218,7 +218,7 @@ def query_all_environment_groups(session, uri, filter) -> Query: EnvironmentGroup.groupUri.ilike('%' + term + '%'), ) ) - return query + return query.order_by(EnvironmentGroup.groupUri) @staticmethod def query_user_consumption_roles(session, username, groups, filter) -> Query: @@ -242,7 +242,7 @@ def query_user_consumption_roles(session, username, groups, filter) -> Query: ConsumptionRole.groupUri == group, ) ) - return query + return query.order_by(ConsumptionRole.consumptionRoleName) @staticmethod def query_user_groups(session, username, groups, filter) -> Query: @@ -258,7 +258,7 @@ def query_user_groups(session, username, groups, filter) -> Query: EnvironmentGroup.groupUri.ilike('%' + term + '%'), ) ) - return query + return query.order_by(EnvironmentGroup.groupUri) @staticmethod def query_user_environments(session, username, groups, filter) -> Query: @@ -287,7 +287,7 @@ def query_user_environments(session, username, groups, filter) -> Query: ) if filter and filter.get('SamlGroupName') and filter.get('SamlGroupName') in groups: query = query.filter(EnvironmentGroup.groupUri == filter.get('SamlGroupName')) - return query + return query.order_by(Environment.label).distinct() @staticmethod def is_user_invited_to_environment(session, groups, uri): diff --git a/backend/dataall/core/organizations/db/organization_repositories.py b/backend/dataall/core/organizations/db/organization_repositories.py index cc404d21d..a04677675 100644 --- a/backend/dataall/core/organizations/db/organization_repositories.py +++ b/backend/dataall/core/organizations/db/organization_repositories.py @@ -48,7 +48,7 @@ def query_user_organizations(session, username, groups, filter) -> Query: models.Organization.tags.contains(f"{{{filter.get('term')}}}"), ) ) - return query + return query.order_by(models.Organization.label).distinct() @staticmethod def paginated_user_organizations(session, data=None) -> dict: @@ -69,7 +69,7 @@ def query_organization_environments(session, uri, filter) -> Query: Environment.description.ilike('%' + filter.get('term') + '%'), ) ) - return query + return query.order_by(Environment.label) @staticmethod def paginated_organization_environments(session, uri, data=None) -> dict: @@ -104,7 +104,7 @@ def query_organization_groups(session, uri, filter) -> Query: models.OrganizationGroup.groupUri.ilike('%' + filter.get('term') + '%'), ) ) - return query + return query.order_by(models.OrganizationGroup.groupUri) @staticmethod def paginated_organization_groups(session, uri, data=None) -> dict: diff --git a/backend/dataall/core/permissions/db/tenant/tenant_policy_repositories.py b/backend/dataall/core/permissions/db/tenant/tenant_policy_repositories.py index 2f27e42d9..e1e2f8255 100644 --- a/backend/dataall/core/permissions/db/tenant/tenant_policy_repositories.py +++ b/backend/dataall/core/permissions/db/tenant/tenant_policy_repositories.py @@ -99,7 +99,7 @@ def list_tenant_groups(session, data=None): query = query.filter(TenantPolicy.principalId.ilike('%' + data.get('term') + '%')) return paginate( - query=query, + query=query.order_by(TenantPolicy.principalId), page=data.get('page', 1), page_size=data.get('pageSize', 10), ).to_dict() diff --git a/backend/dataall/core/vpc/db/vpc_repositories.py b/backend/dataall/core/vpc/db/vpc_repositories.py index 10bad1b9f..f5b4865b6 100644 --- a/backend/dataall/core/vpc/db/vpc_repositories.py +++ b/backend/dataall/core/vpc/db/vpc_repositories.py @@ -50,4 +50,4 @@ def query_environment_networks(session, uri, filter): Vpc.VpcId.ilike('%' + term + '%'), ) ) - return query + return query.order_by(Vpc.label) diff --git a/backend/dataall/modules/catalog/db/glossary_repositories.py b/backend/dataall/modules/catalog/db/glossary_repositories.py index 42387ccbe..eb1a130ff 100644 --- a/backend/dataall/modules/catalog/db/glossary_repositories.py +++ b/backend/dataall/modules/catalog/db/glossary_repositories.py @@ -82,7 +82,9 @@ def list_glossaries(session, data=None): GlossaryNode.readme.ilike('%' + term + '%'), ) ) - return paginate(q, page_size=data.get('pageSize', 10), page=data.get('page', 1)).to_dict() + return paginate( + q.order_by(GlossaryNode.label), page_size=data.get('pageSize', 10), page=data.get('page', 1) + ).to_dict() @staticmethod def list_node_children(session, path, filter): @@ -259,7 +261,9 @@ def list_categories(session, uri, data=None): GlossaryNode.readme.ilike(term), ) ) - return paginate(q, page=data.get('page', 1), page_size=data.get('pageSize', 10)).to_dict() + return paginate( + q.order_by(GlossaryNode.label), page=data.get('page', 1), page_size=data.get('pageSize', 10) + ).to_dict() @staticmethod def list_terms(session, uri, data=None): @@ -278,7 +282,9 @@ def list_terms(session, uri, data=None): GlossaryNode.readme.ilike(term), ) ) - return paginate(q, page=data.get('page', 1), page_size=data.get('pageSize', 10)).to_dict() + return paginate( + q.order_by(GlossaryNode.label), page=data.get('page', 1), page_size=data.get('pageSize', 10) + ).to_dict() @staticmethod def get_node(session, uri) -> GlossaryNode: @@ -399,7 +405,7 @@ def get_glossary_terms_links(session, target_uri, target_type): TermLink.targetType == target_type, ) ) - ) + ).order_by(GlossaryNode.path) return paginate(terms, page_size=10000, page=1).to_dict() diff --git a/backend/dataall/modules/dashboards/db/dashboard_repositories.py b/backend/dataall/modules/dashboards/db/dashboard_repositories.py index 986062384..20478c603 100644 --- a/backend/dataall/modules/dashboards/db/dashboard_repositories.py +++ b/backend/dataall/modules/dashboards/db/dashboard_repositories.py @@ -75,7 +75,7 @@ def _query_user_dashboards(session, username, groups, filter) -> Query: Dashboard.label.ilike(filter.get('term') + '%%'), ) ) - return query + return query.order_by(Dashboard.label).distinct() @staticmethod def paginated_user_dashboards(session, username, groups, data=None) -> dict: @@ -110,7 +110,7 @@ def _query_dashboard_shares(session, username, groups, uri, filter) -> Query: Dashboard.label.ilike(filter.get('term') + '%%'), ) ) - return query + return query.order_by(DashboardShare.shareUri) @staticmethod def query_all_user_groups_shareddashboard(session, groups, uri) -> [str]: diff --git a/backend/dataall/modules/datapipelines/db/datapipelines_repositories.py b/backend/dataall/modules/datapipelines/db/datapipelines_repositories.py index a5c4c6e51..09e84b13e 100644 --- a/backend/dataall/modules/datapipelines/db/datapipelines_repositories.py +++ b/backend/dataall/modules/datapipelines/db/datapipelines_repositories.py @@ -135,7 +135,7 @@ def query_user_pipelines(session, username, groups, filter) -> Query: if filter and filter.get('type'): if len(filter.get('type')) > 0: query = query.filter(DataPipeline.devStrategy.in_(filter.get('type'))) - return query + return query.order_by(DataPipeline.label) @staticmethod def paginated_user_pipelines(session, username, groups, data=None) -> dict: @@ -150,7 +150,7 @@ def query_pipeline_environments(session, uri) -> Query: query = session.query(DataPipelineEnvironment).filter( DataPipelineEnvironment.pipelineUri.ilike(uri + '%%'), ) - return query + return query.order_by(DataPipelineEnvironment.stage) @staticmethod def paginated_pipeline_environments(session, uri, data=None) -> dict: diff --git a/backend/dataall/modules/dataset_sharing/db/share_object_repositories.py b/backend/dataall/modules/dataset_sharing/db/share_object_repositories.py index 716dcb152..5aa7f23fa 100644 --- a/backend/dataall/modules/dataset_sharing/db/share_object_repositories.py +++ b/backend/dataall/modules/dataset_sharing/db/share_object_repositories.py @@ -594,7 +594,9 @@ def list_shareable_items(session, share, states, data): else query.filter(shareable_objects.c.healthStatus != ShareItemHealthStatus.Healthy.value) ) - return paginate(query, data.get('page', 1), data.get('pageSize', 10)).to_dict() + return paginate( + query.order_by(shareable_objects.c.itemName).distinct(), data.get('page', 1), data.get('pageSize', 10) + ).to_dict() @staticmethod def list_user_received_share_requests(session, username, groups, data=None): @@ -629,7 +631,7 @@ def list_user_received_share_requests(session, username, groups, data=None): if data and data.get('share_iam_roles'): if len(data.get('share_iam_roles')) > 0: query = query.filter(ShareObject.principalIAMRoleName.in_(data.get('share_iam_roles'))) - return paginate(query, data.get('page', 1), data.get('pageSize', 10)).to_dict() + return paginate(query.order_by(ShareObject.shareUri), data.get('page', 1), data.get('pageSize', 10)).to_dict() @staticmethod def list_user_sent_share_requests(session, username, groups, data=None): @@ -668,7 +670,7 @@ def list_user_sent_share_requests(session, username, groups, data=None): if data and data.get('share_iam_roles'): if len(data.get('share_iam_roles')) > 0: query = query.filter(ShareObject.principalIAMRoleName.in_(data.get('share_iam_roles'))) - return paginate(query, data.get('page', 1), data.get('pageSize', 10)).to_dict() + return paginate(query.order_by(ShareObject.shareUri), data.get('page', 1), data.get('pageSize', 10)).to_dict() @staticmethod def get_share_by_dataset_and_environment(session, dataset_uri, environment_uri): @@ -1001,11 +1003,15 @@ def find_dataset_shares(session, dataset_uri): @staticmethod def query_dataset_shares(session, dataset_uri) -> Query: - return session.query(ShareObject).filter( - and_( - ShareObject.datasetUri == dataset_uri, - ShareObject.deleted.is_(None), + return ( + session.query(ShareObject) + .filter( + and_( + ShareObject.datasetUri == dataset_uri, + ShareObject.deleted.is_(None), + ) ) + .order_by(ShareObject.shareUri) ) @staticmethod @@ -1157,7 +1163,9 @@ def paginate_shared_datasets(session, env_uri, data): if data.get('uniqueShares', False): q = q.filter(ShareObject.principalType != PrincipalType.ConsumptionRole.value) - q = q.distinct(ShareObject.shareUri) + q = q.order_by(ShareObject.shareUri).distinct(ShareObject.shareUri) + else: + q = q.order_by(ShareObjectItem.itemName).distinct() if data.get('term'): term = data.get('term') diff --git a/backend/dataall/modules/datasets/api/table_column/resolvers.py b/backend/dataall/modules/datasets/api/table_column/resolvers.py index 5cb1a8342..155dea92f 100644 --- a/backend/dataall/modules/datasets/api/table_column/resolvers.py +++ b/backend/dataall/modules/datasets/api/table_column/resolvers.py @@ -29,7 +29,7 @@ def resolve_terms(context, source: DatasetTableColumn, **kwargs): return None with context.engine.scoped_session() as session: q = session.query(TermLink).filter(TermLink.targetUri == source.columnUri) - return paginate(q, page=1, page_size=15).to_dict() + return paginate(q.order_by(TermLink.linkUri), page=1, page_size=15).to_dict() def update_table_column(context: Context, source, columnUri: str = None, input: dict = None): diff --git a/backend/dataall/modules/datasets/db/dataset_location_repositories.py b/backend/dataall/modules/datasets/db/dataset_location_repositories.py index 8cb8c1e45..2be75c299 100644 --- a/backend/dataall/modules/datasets/db/dataset_location_repositories.py +++ b/backend/dataall/modules/datasets/db/dataset_location_repositories.py @@ -113,4 +113,8 @@ def paginated_dataset_locations(session, uri, data=None) -> dict: ] ) ) - return paginate(query=query, page_size=data.get('pageSize', 10), page=data.get('page', 1)).to_dict() + return paginate( + query=query.order_by(DatasetStorageLocation.label), + page_size=data.get('pageSize', 10), + page=data.get('page', 1), + ).to_dict() diff --git a/backend/dataall/modules/datasets/db/dataset_repositories.py b/backend/dataall/modules/datasets/db/dataset_repositories.py index 6de362c97..847780c59 100644 --- a/backend/dataall/modules/datasets/db/dataset_repositories.py +++ b/backend/dataall/modules/datasets/db/dataset_repositories.py @@ -179,7 +179,7 @@ def _query_all_user_datasets(session, username, groups, all_subqueries, filter) Dataset.label.ilike(filter.get('term') + '%%'), ) ) - return query.distinct(Dataset.datasetUri) + return query.order_by(Dataset.label).distinct(Dataset.datasetUri, Dataset.label) @staticmethod def paginated_dataset_tables(session, uri, data=None) -> dict: @@ -279,7 +279,7 @@ def query_environment_group_datasets(session, env_uri, group_uri, filter) -> Que Dataset.region.ilike('%' + term + '%'), ) ) - return query + return query.order_by(Dataset.label) @staticmethod def query_environment_datasets(session, uri, filter) -> Query: @@ -299,7 +299,7 @@ def query_environment_datasets(session, uri, filter) -> Query: Dataset.region.ilike('%' + term + '%'), ) ) - return query + return query.order_by(Dataset.label) @staticmethod def query_environment_imported_datasets(session, uri, filter) -> Query: @@ -375,7 +375,7 @@ def _query_user_datasets(session, username, groups, filter) -> Query: Dataset.label.ilike(filter.get('term') + '%%'), ) ) - return query.distinct(Dataset.datasetUri) + return query.order_by(Dataset.label).distinct(Dataset.datasetUri, Dataset.label) @staticmethod def _set_import_data(dataset, data): diff --git a/backend/dataall/modules/mlstudio/db/mlstudio_repositories.py b/backend/dataall/modules/mlstudio/db/mlstudio_repositories.py index 0ddd82f2c..29c7d2e0b 100644 --- a/backend/dataall/modules/mlstudio/db/mlstudio_repositories.py +++ b/backend/dataall/modules/mlstudio/db/mlstudio_repositories.py @@ -44,7 +44,7 @@ def _query_user_sagemaker_studio_users(session, username, groups, filter) -> Que SagemakerStudioUser.label.ilike(filter.get('term') + '%%'), ) ) - return query + return query.order_by(SagemakerStudioUser.label) @staticmethod def paginated_sagemaker_studio_users(session, username, groups, filter={}) -> dict: diff --git a/backend/dataall/modules/notebooks/db/notebook_repository.py b/backend/dataall/modules/notebooks/db/notebook_repository.py index 30be51560..c7ad805c9 100644 --- a/backend/dataall/modules/notebooks/db/notebook_repository.py +++ b/backend/dataall/modules/notebooks/db/notebook_repository.py @@ -52,7 +52,7 @@ def _query_user_notebooks(self, username, groups, filter) -> Query: SagemakerNotebook.label.ilike(filter.get('term') + '%%'), ) ) - return query + return query.order_by(SagemakerNotebook.label) def count_resources(self, environment_uri, group_uri): return ( diff --git a/backend/dataall/modules/notifications/db/notification_repositories.py b/backend/dataall/modules/notifications/db/notification_repositories.py index 9510097b5..34ff7d1c6 100644 --- a/backend/dataall/modules/notifications/db/notification_repositories.py +++ b/backend/dataall/modules/notifications/db/notification_repositories.py @@ -49,7 +49,11 @@ def paginated_notifications(session, username, groups, filter=None): ) if filter.get('archived'): q = q.filter(models.Notification.deleted.isnot(None)) - return paginate(q, page=filter.get('page', 1), page_size=filter.get('pageSize', 20)).to_dict() + return paginate( + q.order_by(models.Notification.created.desc()), + page=filter.get('page', 1), + page_size=filter.get('pageSize', 20), + ).to_dict() @staticmethod def count_unread_notifications(session, username, groups): diff --git a/backend/dataall/modules/worksheets/db/worksheet_repositories.py b/backend/dataall/modules/worksheets/db/worksheet_repositories.py index c6ed151fb..aea51761b 100644 --- a/backend/dataall/modules/worksheets/db/worksheet_repositories.py +++ b/backend/dataall/modules/worksheets/db/worksheet_repositories.py @@ -44,7 +44,7 @@ def query_user_worksheets(session, username, groups, filter) -> Query: Worksheet.tags.contains(f"{{{filter.get('term')}}}"), ) ) - return query + return query.order_by(Worksheet.label) @staticmethod def paginated_user_worksheets(session, username, groups, uri, data=None, check_perm=None) -> dict: