Fix performances on view loading (#14859)
## Context We are experiencing bad performance on Twenty. One of the root cause hypothesis is that computing `currentUser.currentWorkspace.views` is CPU consuming. Without views, the GetCurrentUser response is ~1000 lines. With its ~10000 lines. As graphql is going through all fields recursively this can be quite heavy on CPU. We had a similar issues on ObjectMetadataItems 2 years ago and came with storing the response in redis. Note: I thought there was also a cache in RAM but this is not the case, so to invalidate the cache we can just empty redis. ## How - Extract getting all views from GetCurrentUser and update frontend to perform both queries - Add views to cached graphql operations - invalidate the cache manually on view or related core entities update / create / delete / destroy ## Tests I have tested a lot on v1
This commit is contained in:
+4
@@ -116,6 +116,7 @@ export class FieldMetadataRelatedRecordsService {
|
||||
|
||||
await this.syncNoValueViewGroup(newFieldMetadata, view);
|
||||
}
|
||||
await this.viewService.flushGraphQLCache(newFieldMetadata.workspaceId);
|
||||
}
|
||||
|
||||
public async resetViewKanbanAggregateOperation(
|
||||
@@ -140,6 +141,7 @@ export class FieldMetadataRelatedRecordsService {
|
||||
kanbanAggregateOperation: null,
|
||||
});
|
||||
}
|
||||
await this.viewService.flushGraphQLCache(fieldMetadata.workspaceId);
|
||||
}
|
||||
|
||||
public async updateRelatedViewFilters(
|
||||
@@ -247,6 +249,7 @@ export class FieldMetadataRelatedRecordsService {
|
||||
);
|
||||
}
|
||||
}
|
||||
await this.viewService.flushGraphQLCache(newFieldMetadata.workspaceId);
|
||||
}
|
||||
|
||||
async syncNoValueViewGroup(
|
||||
@@ -274,6 +277,7 @@ export class FieldMetadataRelatedRecordsService {
|
||||
fieldMetadata.workspaceId,
|
||||
);
|
||||
}
|
||||
await this.viewService.flushGraphQLCache(fieldMetadata.workspaceId);
|
||||
}
|
||||
|
||||
public getOptionsDifferences(
|
||||
|
||||
+1
@@ -34,6 +34,7 @@ export class ObjectMetadataRelatedRecordsService {
|
||||
|
||||
await this.createViewFields(objectMetadata, view.id);
|
||||
await this.createViewWorkspaceFavorite(objectMetadata.workspaceId, view.id);
|
||||
await this.viewService.flushGraphQLCache(objectMetadata.workspaceId);
|
||||
}
|
||||
|
||||
public async updateLabelMetadataIdentifierInObjectViews({
|
||||
|
||||
Reference in New Issue
Block a user