Improve performance on metadata computation (#12785)
In this PR: ## Improve recompute metadata cache performance. We are aiming for ~100ms Deleting relationMetadata table and FKs pointing on it Fetching indexMetadata and indexFieldMetadata in a separate query as typeorm is suboptimizing ## Remove caching lock As recomputing the metadata cache is lighter, we try to stop preventing multiple concurrent computations. This also simplifies interfaces ## Introduce self recovery mecanisms to recompute cache automatically if corrupted Aka getFreshObjectMetadataMaps ## custom object resolver performance improvement: 1sec to 200ms Double check queries and indexes used while creating a custom object Remove the queries to db to use the cached objectMetadataMap ## reduce objectMetadataMaps to 500kb <img width="222" alt="image" src="https://github.com/user-attachments/assets/2370dc80-49b6-4b63-8d5e-30c5ebdaa062" /> We used to stored 3 fieldMetadataMaps (byId, byName, byJoinColumnName). While this is great for devXP, this is not great for performances. Using the same mecanisme as for objectMetadataMap: we only keep byIdMap and introduce two otherMaps to idByName, idByJoinColumnName to make the bridge ## Add dataloader on IndexMetadata (aka indexMetadataList in the API) ## Improve field resolver performances too ## Deprecate ClientConfig
This commit is contained in:
@ -1,75 +0,0 @@
|
||||
import { gql } from '@apollo/client';
|
||||
|
||||
export const GET_CLIENT_CONFIG = gql`
|
||||
query GetClientConfig {
|
||||
clientConfig {
|
||||
aiModels {
|
||||
modelId
|
||||
label
|
||||
provider
|
||||
inputCostPer1kTokensInCredits
|
||||
outputCostPer1kTokensInCredits
|
||||
}
|
||||
billing {
|
||||
isBillingEnabled
|
||||
billingUrl
|
||||
trialPeriods {
|
||||
duration
|
||||
isCreditCardRequired
|
||||
}
|
||||
}
|
||||
authProviders {
|
||||
google
|
||||
password
|
||||
microsoft
|
||||
sso {
|
||||
id
|
||||
name
|
||||
type
|
||||
status
|
||||
issuer
|
||||
}
|
||||
}
|
||||
signInPrefilled
|
||||
isMultiWorkspaceEnabled
|
||||
isEmailVerificationRequired
|
||||
defaultSubdomain
|
||||
frontDomain
|
||||
debugMode
|
||||
analyticsEnabled
|
||||
isAttachmentPreviewEnabled
|
||||
support {
|
||||
supportDriver
|
||||
supportFrontChatId
|
||||
}
|
||||
sentry {
|
||||
dsn
|
||||
environment
|
||||
release
|
||||
}
|
||||
captcha {
|
||||
provider
|
||||
siteKey
|
||||
}
|
||||
api {
|
||||
mutationMaximumAffectedRecords
|
||||
}
|
||||
chromeExtensionId
|
||||
canManageFeatureFlags
|
||||
publicFeatureFlags {
|
||||
key
|
||||
metadata {
|
||||
label
|
||||
description
|
||||
imagePath
|
||||
}
|
||||
}
|
||||
isMicrosoftMessagingEnabled
|
||||
isMicrosoftCalendarEnabled
|
||||
isGoogleMessagingEnabled
|
||||
isGoogleCalendarEnabled
|
||||
isConfigVariablesInDbEnabled
|
||||
calendarBookingPageId
|
||||
}
|
||||
}
|
||||
`;
|
||||
@ -1,6 +1,6 @@
|
||||
import { ClientConfig } from '@/client-config/types/ClientConfig';
|
||||
import { useCallback } from 'react';
|
||||
import { useRecoilValue, useSetRecoilState } from 'recoil';
|
||||
import { ClientConfig } from '~/generated/graphql';
|
||||
import { clientConfigApiStatusState } from '../states/clientConfigApiStatusState';
|
||||
import { getClientConfig } from '../utils/getClientConfig';
|
||||
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
import { ClientConfig } from '@/client-config/types/ClientConfig';
|
||||
import { createState } from 'twenty-ui/utilities';
|
||||
import { ClientConfig } from '~/generated/graphql';
|
||||
|
||||
type ClientConfigApiStatus = {
|
||||
isLoadedOnce: boolean;
|
||||
|
||||
@ -0,0 +1,37 @@
|
||||
import {
|
||||
ApiConfig,
|
||||
AuthProviders,
|
||||
Billing,
|
||||
Captcha,
|
||||
ClientAiModelConfig,
|
||||
PublicFeatureFlag,
|
||||
Sentry,
|
||||
Support,
|
||||
} from '~/generated-metadata/graphql';
|
||||
|
||||
export type ClientConfig = {
|
||||
aiModels: Array<ClientAiModelConfig>;
|
||||
analyticsEnabled: boolean;
|
||||
api: ApiConfig;
|
||||
authProviders: AuthProviders;
|
||||
billing: Billing;
|
||||
calendarBookingPageId?: string;
|
||||
canManageFeatureFlags: boolean;
|
||||
captcha: Captcha;
|
||||
chromeExtensionId?: string;
|
||||
debugMode: boolean;
|
||||
defaultSubdomain?: string;
|
||||
frontDomain: string;
|
||||
isAttachmentPreviewEnabled: boolean;
|
||||
isConfigVariablesInDbEnabled: boolean;
|
||||
isEmailVerificationRequired: boolean;
|
||||
isGoogleCalendarEnabled: boolean;
|
||||
isGoogleMessagingEnabled: boolean;
|
||||
isMicrosoftCalendarEnabled: boolean;
|
||||
isMicrosoftMessagingEnabled: boolean;
|
||||
isMultiWorkspaceEnabled: boolean;
|
||||
publicFeatureFlags: Array<PublicFeatureFlag>;
|
||||
sentry: Sentry;
|
||||
signInPrefilled: boolean;
|
||||
support: Support;
|
||||
};
|
||||
@ -1,5 +1,5 @@
|
||||
import { ClientConfig } from '@/client-config/types/ClientConfig';
|
||||
import { REACT_APP_SERVER_BASE_URL } from '~/config';
|
||||
import { ClientConfig } from '~/generated/graphql';
|
||||
|
||||
export const getClientConfig = async (): Promise<ClientConfig> => {
|
||||
const response = await fetch(`${REACT_APP_SERVER_BASE_URL}/client-config`, {
|
||||
|
||||
Reference in New Issue
Block a user