Skip to content
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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

* _Contributing to this repo? Add info about your change here to be included in next release_

* Improvement: Data browser updates object count when table is filtered (#652), thanks to [Mike Rizzo](https://github.com/rizzomichaelg)

### 1.0.23
* Improvement: Enabling web hooks (#584), thanks to [Antonio Davi Macedo Coelho de Castro](https://github.com/davimacedo)
* Improvement: Set autofocus on the username input field (#644), thanks to [Herman Liang](https://github.com/hermanliang)
Expand Down
27 changes: 25 additions & 2 deletions src/dashboard/Data/Browser/Browser.react.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ export default class Browser extends DashboardView {

relation: null,
counts: {},
filteredCounts: {},
clp: {},
filters: new List(),
ordering: '-createdAt',
Expand Down Expand Up @@ -320,9 +321,21 @@ export default class Browser extends DashboardView {
return data;
}

async fetchParseDataCount(source, filters) {
const query = queryFromFilters(source, filters);
const count = await query.count({ useMasterKey: true });
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Potential performance issue - if a filter uses non-indexed fields then count() will perform a colscan. This could also happen in fetchParseData so may not be a concern, however count has no option to early exit by hitting a limit whereas fetchParseData does.

I'm not sure how to solve this, perhaps have to rely on parse-server having databaseOptions.maxTimeMS specified?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You raise a great point.

Besides relying on the parse-server timeout, we could also add a restriction on when the count will update and only update if the total number of objects in the table is less than a certain constant. Not super excited about this option, though. Might be best to rely on the server's timeout.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think - let's merge it for now and look at optimizations in a separate PR, unless you want to try anything different?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@steven-supersolid I want to release a new version including the Jobs fix, so I'm ok merging this and improving later.

return count;
}

async fetchData(source, filters = new List(), last) {
const data = await this.fetchParseData(source, filters);
this.setState({ data: data, filters, lastMax: 200 });
var filteredCounts = { ...this.state.filteredCounts };
if (filters.length > 0) {
filteredCounts[source] = await this.fetchParseDataCount(source,filters);
} else {
delete filteredCounts[source];
}
this.setState({ data: data, filters, lastMax: 200 , filteredCounts: filteredCounts});
}

async fetchRelation(relation, filters = new List()) {
Expand Down Expand Up @@ -781,9 +794,19 @@ export default class Browser extends DashboardView {
columns[name] = info;
});

var count;
if (this.state.relation) {
count = this.state.relationCount;
} else {
if (className in this.state.filteredCounts) {
count = this.state.filteredCounts[className];
} else {
count = this.state.counts[className];
}
}
browser = (
<DataBrowser
count={this.state.relation ? this.state.relationCount : this.state.counts[className]}
count={count}
perms={this.state.clp[className]}
schema={schema}
userPointers={userPointers}
Expand Down