Skip to content

Commit

Permalink
Make query distinct on dataaset for worksheet view (#304)
Browse files Browse the repository at this point in the history
### Feature or Bugfix
- Bugfix

### Detail
- Fix bug in worksheet showing duplicated databases

### Relates
- #287 

By submitting this pull request, I confirm that my contribution is made
under the terms of the Apache 2.0 license.
  • Loading branch information
noah-paige committed Feb 13, 2023
1 parent 3f836af commit cdb9018
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions backend/dataall/api/Objects/Environment/input_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ class EnvironmentSortField(GraphQLEnumMapper):
gql.Argument('term', gql.String),
gql.Argument('page', gql.Integer),
gql.Argument('pageSize', gql.Integer),
gql.Argument('uniqueDatasets', gql.Boolean)
],
)

Expand Down
4 changes: 4 additions & 0 deletions backend/dataall/db/api/environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -940,6 +940,10 @@ def paginated_shared_with_environment_datasets(
q = q.filter(
or_(*[models.ShareObjectItem.itemType == t for t in itemTypes])
)

if data.get("uniqueDatasets", False):
q = q.distinct(models.ShareObject.datasetUri)

if data.get('term'):
term = data.get('term')
q = q.filter(models.ShareObjectItem.itemName.ilike('%' + term + '%'))
Expand Down
1 change: 1 addition & 0 deletions frontend/src/views/Worksheets/WorksheetView.js
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ const WorksheetView = () => {
page: 1,
pageSize: 10000,
term: '',
uniqueDatasets: true,
itemTypes: 'DatasetTable'
}
})
Expand Down

0 comments on commit cdb9018

Please sign in to comment.