Skip to content

Commit

Permalink
fix: revert parse-community#1706 which introduced new database index …
Browse files Browse the repository at this point in the history
…requirements for pagination (parse-community#1800)
  • Loading branch information
Christopher Brookes authored Sep 16, 2021
1 parent 802c8fd commit 689df7c
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 30 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,14 @@

## Improvements
- Update sass to 5.0.0 and make docker image use node:lts-alpine (Corey Baker) [#1792](https://github.com/parse-community/parse-dashboard/pull/1792)
- Docker image use now node 12 version [#1788](https://github.com/parse-community/parse-dashboard/pull/1788)
- Docker image use now node 12 version (Christopher Brookes) [#1788](https://github.com/parse-community/parse-dashboard/pull/1788)
- CI now pushes docker images to Docker Hub (Corey Baker) [#1781](https://github.com/parse-community/parse-dashboard/pull/1781)
- Add CI check to add changelog entry (Manuel Trezza) [#1764](https://github.com/parse-community/parse-dashboard/pull/1764)
- Refactor: uniform issue templates across repos (Manuel Trezza) [#1767](https://github.com/parse-community/parse-dashboard/pull/1767)
- fix: date cell value not selected on double clicks (fn-faisal) [#1730](https://github.com/parse-community/parse-dashboard/pull/1730)

## Fixes
- Revert PR [#1706](https://github.com/parse-community/parse-dashboard/pull/1706) which introduced new database index requirements for pagination and was a breaking change that can lead to database performance issues if database indices are not adapted (Christopher Brookes) [#1800](https://github.com/parse-community/parse-dashboard/pull/1800)
- Fixed bug after creating new class, wrong CLP was shown for that class [#1784](https://github.com/parse-community/parse-dashboard/issues/1784) (Prerna Mehra) [#1785](https://github.com/parse-community/parse-dashboard/pull/1785)
- Fixed bug when opening a big modal, modal content is not visible due to Sidebar (Prerna Mehra) [#1777](https://github.com/parse-community/parse-dashboard/pull/1778)
- Fixed UI for a field containing an array of pointers (Prerna Mehra) [#1776](https://github.com/parse-community/parse-dashboard/pull/1776)
Expand Down
49 changes: 20 additions & 29 deletions src/dashboard/Data/Browser/Browser.react.js
Original file line number Diff line number Diff line change
Expand Up @@ -647,14 +647,6 @@ class Browser extends DashboardView {
query.ascending(field)
}

if (field !== 'objectId') {
if (sortDir === '-') {
query.addDescending('objectId');
} else {
query.addAscending('objectId');
}
}

query.limit(MAX_ROWS_FETCHED);
this.excludeFields(query, source);

Expand Down Expand Up @@ -732,38 +724,37 @@ class Browser extends DashboardView {
let className = this.props.params.className;
let source = this.state.relation || className;
let query = queryFromFilters(source, this.state.filters);
let field = this.state.ordering;
let sortDir = field[0] === '-' ? '-' : '+';
field = field[0] === '-' ? field.slice(1) : field;
if (this.state.ordering !== '-objectId' && this.state.ordering !== 'objectId') {
if (this.state.ordering !== '-createdAt') {
// Construct complex pagination query
let equalityQuery = queryFromFilters(source, this.state.filters);
let field = this.state.ordering;
let ascending = true;
let comp = this.state.data[this.state.data.length - 1].get(field);

if (sortDir === '-') {
if (field === 'objectId' || field === '-objectId') {
comp = this.state.data[this.state.data.length - 1].id;
}
if (field[0] === '-') {
field = field.substr(1);
query.lessThan(field, comp);
equalityQuery.lessThan('objectId', this.state.data[this.state.data.length - 1].id);
ascending = false;
} else {
query.greaterThan(field, comp);
equalityQuery.greaterThan('objectId', this.state.data[this.state.data.length - 1].id);
}
equalityQuery.equalTo(field, comp);
query = Parse.Query.or(query, equalityQuery);
if (sortDir === '-') {
query.descending(field);
query.addDescending('objectId');
if (field === 'createdAt') {
equalityQuery.greaterThan('createdAt', this.state.data[this.state.data.length - 1].get('createdAt'));
} else {
query.ascending(field);
query.addAscending('objectId');
equalityQuery.lessThan('createdAt', this.state.data[this.state.data.length - 1].get('createdAt'));
equalityQuery.equalTo(field, comp);
}
} else {
if (sortDir === '-') {
query.lessThan('objectId', this.state.data[this.state.data.length - 1].id);
query.addDescending('objectId');
query = Parse.Query.or(query, equalityQuery);
if (ascending) {
query.ascending(this.state.ordering);
} else {
query.greaterThan('objectId', this.state.data[this.state.data.length - 1].id);
query.addAscending('objectId');
query.descending(this.state.ordering.substr(1));
}
} else {
query.lessThan('createdAt', this.state.data[this.state.data.length - 1].get('createdAt'));
query.addDescending('createdAt');
}
query.limit(MAX_ROWS_FETCHED);
this.excludeFields(query, source);
Expand Down

0 comments on commit 689df7c

Please sign in to comment.