mirror of
https://github.com/twentyhq/twenty.git
synced 2024-11-29 01:38:18 +03:00
Fix performance (#7131)
This commit is contained in:
parent
41fe8f7fea
commit
210c336ccf
@ -40,11 +40,11 @@ export class GraphqlQueryParser {
|
||||
|
||||
const parsedFilter = graphqlQueryFilterParser.parse(recordFilter);
|
||||
|
||||
if (!('deletedAt' in this.fieldMetadataMap)) {
|
||||
// if (!('deletedAt' in this.fieldMetadataMap)) {
|
||||
return parsedFilter;
|
||||
}
|
||||
// }
|
||||
|
||||
return this.addDefaultSoftDeleteCondition(parsedFilter);
|
||||
// return this.addDefaultSoftDeleteCondition(parsedFilter);
|
||||
}
|
||||
|
||||
private addDefaultSoftDeleteCondition(
|
||||
|
@ -65,6 +65,7 @@ export class GraphqlQueryFindOneResolverService {
|
||||
where,
|
||||
select,
|
||||
})) as ObjectRecord;
|
||||
|
||||
const limit = QUERY_MAX_RECORDS;
|
||||
|
||||
if (!objectRecord) {
|
||||
|
@ -79,7 +79,6 @@ export class EntitySchemaColumnFactory {
|
||||
nullable: fieldMetadata.isNullable,
|
||||
createDate: key === 'createdAt',
|
||||
updateDate: key === 'updatedAt',
|
||||
deleteDate: key === 'deletedAt',
|
||||
array: fieldMetadata.type === FieldMetadataType.MULTI_SELECT,
|
||||
default: defaultValue,
|
||||
};
|
||||
|
@ -4,7 +4,6 @@ import { EntitySchema } from 'typeorm';
|
||||
|
||||
import { EnvironmentService } from 'src/engine/core-modules/environment/environment.service';
|
||||
import { DataSourceService } from 'src/engine/metadata-modules/data-source/data-source.service';
|
||||
import { ObjectMetadataMap } from 'src/engine/metadata-modules/utils/generate-object-metadata-map.util';
|
||||
import { WorkspaceMetadataCacheService } from 'src/engine/metadata-modules/workspace-metadata-cache/services/workspace-metadata-cache.service';
|
||||
import { WorkspaceDataSource } from 'src/engine/twenty-orm/datasource/workspace.datasource';
|
||||
import {
|
||||
@ -36,10 +35,8 @@ export class WorkspaceDatasourceFactory {
|
||||
workspaceMetadataVersion: number | null,
|
||||
failOnMetadataCacheMiss = true,
|
||||
): Promise<WorkspaceDataSource> {
|
||||
const {
|
||||
metadataVersion: cachedWorkspaceMetadataVersion,
|
||||
objectMetadataMap: cachedObjectMetadataMap,
|
||||
} = await this.getWorkspaceMetadataFromCache(
|
||||
const cachedWorkspaceMetadataVersion =
|
||||
await this.getWorkspaceMetadataVersionFromCache(
|
||||
workspaceId,
|
||||
failOnMetadataCacheMiss,
|
||||
);
|
||||
@ -89,6 +86,19 @@ export class WorkspaceDatasourceFactory {
|
||||
|
||||
let cachedEntitySchemas: EntitySchema[];
|
||||
|
||||
const cachedObjectMetadataMap =
|
||||
await this.workspaceCacheStorageService.getObjectMetadataMap(
|
||||
workspaceId,
|
||||
cachedWorkspaceMetadataVersion,
|
||||
);
|
||||
|
||||
if (!cachedObjectMetadataMap) {
|
||||
throw new TwentyORMException(
|
||||
`Workspace Schema not found for workspace ${workspaceId}`,
|
||||
TwentyORMExceptionCode.METADATA_COLLECTION_NOT_FOUND,
|
||||
);
|
||||
}
|
||||
|
||||
if (cachedEntitySchemaOptions) {
|
||||
cachedEntitySchemas = cachedEntitySchemaOptions.map(
|
||||
(option) => new EntitySchema(option),
|
||||
@ -181,13 +191,10 @@ export class WorkspaceDatasourceFactory {
|
||||
);
|
||||
}
|
||||
|
||||
private async getWorkspaceMetadataFromCache(
|
||||
private async getWorkspaceMetadataVersionFromCache(
|
||||
workspaceId: string,
|
||||
failOnMetadataCacheMiss = true,
|
||||
): Promise<{
|
||||
metadataVersion: number;
|
||||
objectMetadataMap: ObjectMetadataMap;
|
||||
}> {
|
||||
): Promise<number> {
|
||||
let latestWorkspaceMetadataVersion =
|
||||
await this.workspaceCacheStorageService.getMetadataVersion(workspaceId);
|
||||
|
||||
@ -217,22 +224,6 @@ export class WorkspaceDatasourceFactory {
|
||||
);
|
||||
}
|
||||
|
||||
const objectMetadataMap =
|
||||
await this.workspaceCacheStorageService.getObjectMetadataMap(
|
||||
workspaceId,
|
||||
latestWorkspaceMetadataVersion,
|
||||
);
|
||||
|
||||
if (!objectMetadataMap) {
|
||||
throw new TwentyORMException(
|
||||
`Object metadata map not found for workspace ${workspaceId}`,
|
||||
TwentyORMExceptionCode.METADATA_COLLECTION_NOT_FOUND,
|
||||
);
|
||||
}
|
||||
|
||||
return {
|
||||
metadataVersion: latestWorkspaceMetadataVersion,
|
||||
objectMetadataMap,
|
||||
};
|
||||
return latestWorkspaceMetadataVersion;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user