mirror of
https://github.com/gristlabs/grist-core.git
synced 2026-03-02 04:09:24 +00:00
Optimize sql query for workspace acl (#824)
Without this optimization, we fetched loads of entries from the database, which led to database and nodejs overloads. We could go further, this is a modest patch towards better performance. We use two queries: one fetches the workspaces, the second the organization that the workspace belongs to. --------- Co-authored-by: Florent FAYOLLE <florent.fayolle@beta.gouv.fr>
This commit is contained in:
@@ -924,6 +924,21 @@ describe('ApiServerAccess', function() {
|
||||
isMember: true,
|
||||
}]
|
||||
});
|
||||
|
||||
const deltaOrg = {
|
||||
users: {
|
||||
[kiwiEmail]: "owners",
|
||||
}
|
||||
};
|
||||
const respDeltaOrg = await axios.patch(`${homeUrl}/api/orgs/${oid}/access`, {delta: deltaOrg}, chimpy);
|
||||
assert.equal(respDeltaOrg.status, 200);
|
||||
|
||||
const resp3 = await axios.get(`${homeUrl}/api/workspaces/${wid}/access`, chimpy);
|
||||
assert.include(resp3.data.users.find((user: any) => user.email === kiwiEmail), {
|
||||
access: "editors",
|
||||
parentAccess: "owners"
|
||||
});
|
||||
|
||||
// Reset the access settings
|
||||
const resetDelta = {
|
||||
maxInheritedRole: "owners",
|
||||
@@ -933,6 +948,13 @@ describe('ApiServerAccess', function() {
|
||||
};
|
||||
const resetResp = await axios.patch(`${homeUrl}/api/workspaces/${wid}/access`, {delta: resetDelta}, chimpy);
|
||||
assert.equal(resetResp.status, 200);
|
||||
const resetOrgDelta = {
|
||||
users: {
|
||||
[kiwiEmail]: "members",
|
||||
}
|
||||
};
|
||||
const resetOrgResp = await axios.patch(`${homeUrl}/api/orgs/${oid}/access`, {delta: resetOrgDelta}, chimpy);
|
||||
assert.equal(resetOrgResp.status, 200);
|
||||
|
||||
// Assert that ws guests are properly displayed.
|
||||
// Tests a minor bug that showed ws guests as having null access.
|
||||
|
||||
@@ -22,6 +22,7 @@ import * as path from 'path';
|
||||
import {createInitialDb, removeConnection, setUpDB} from 'test/gen-server/seed';
|
||||
import {setPlan} from 'test/gen-server/testUtils';
|
||||
import {fixturesRoot} from 'test/server/testUtils';
|
||||
import {isAffirmative} from 'app/common/gutil';
|
||||
|
||||
export class TestServer {
|
||||
public serverUrl: string;
|
||||
@@ -36,7 +37,7 @@ export class TestServer {
|
||||
public async start(servers: ServerType[] = ["home"],
|
||||
options: FlexServerOptions = {}): Promise<string> {
|
||||
await createInitialDb();
|
||||
this.server = await mergedServerMain(0, servers, {logToConsole: false,
|
||||
this.server = await mergedServerMain(0, servers, {logToConsole: isAffirmative(process.env.DEBUG),
|
||||
externalStorage: false,
|
||||
...options});
|
||||
this.serverUrl = this.server.getOwnUrl();
|
||||
|
||||
Reference in New Issue
Block a user