Skip to content

fix: revert #1706 which introduced new database index requirements for pagination #1800

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 16, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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