(core) Log number of rows in user tables in data engine

Summary:
Adds a method Table._num_rows using an empty lookup map column.

Adds a method Engine.count_rows which adds them all up.

Returns the count after applying user actions to be logged by ActiveDoc.

Test Plan: Added a unit test in Python. Tested log message manually.

Reviewers: paulfitz

Reviewed By: paulfitz

Differential Revision: https://phab.getgrist.com/D3275
This commit is contained in:
Alex Hall
2022-02-21 16:19:11 +02:00
parent f1002c0e67
commit 437d30bd9f
13 changed files with 84 additions and 15 deletions

View File

@@ -61,6 +61,7 @@ export interface SandboxActionBundle {
calc: Array<EnvContent<DocAction>>;
undo: Array<EnvContent<DocAction>>; // Inverse actions for all 'stored' actions.
retValues: any[]; // Contains retValue for each of userActions.
rowCount: number;
}
// Local action that's been applied. It now has an actionNum, and includes doc actions packaged

View File

@@ -1216,6 +1216,10 @@ export class ActiveDoc extends EventEmitter {
}
const user = docSession ? await this._granularAccess.getCachedUser(docSession) : undefined;
sandboxActionBundle = await this._rawPyCall('apply_user_actions', normalActions, user?.toJSON());
log.rawInfo('Sandbox row count', {
...this.getLogMeta(docSession),
rowCount: sandboxActionBundle.rowCount
});
await this._reportDataEngineMemory();
} else {
// Create default SandboxActionBundle to use if the data engine is not called.
@@ -1736,7 +1740,8 @@ function createEmptySandboxActionBundle(): SandboxActionBundle {
direct: [],
calc: [],
undo: [],
retValues: []
retValues: [],
rowCount: 0,
};
}