Improve performances (#14869)

## Improvements

- Add logs to all gql operations and rest calls to help debug CPU issues
on the backend. These are temporary and should be removed
- Remove nested relations from workflowVersions load (used to add manual
triggers in the side bar). On some workspaces this call result in a
response of 4MB which is heavy on CPU
- Investigated Redis Usage ==> made a few improvements, we are should
still migrate to the new cache service once available
- investigated db calls in messaging / calendar fetch list + workflow
enqueue run cron jobs. Everything seems to be properly batched
This commit is contained in:
Charles Bochet
2025-10-03 17:22:03 +02:00
committed by GitHub
parent f973a1bcdb
commit c5cdf45f85
19 changed files with 308 additions and 199 deletions
@@ -1,14 +1,16 @@
import { CoreObjectNameSingular } from '@/object-metadata/types/CoreObjectNameSingular';
import { useFindManyRecords } from '@/object-record/hooks/useFindManyRecords';
import { type Workflow, type WorkflowVersion } from '@/workflow/types/Workflow';
import { type WorkflowVersion } from '@/workflow/types/Workflow';
export const useActiveWorkflowVersion = (workflowId: string) => {
type UseActiveWorkflowVersionProps = {
workflowId: string;
};
export const useActiveWorkflowVersion = ({
workflowId,
}: UseActiveWorkflowVersionProps) => {
const { records: workflowVersions, loading } = useFindManyRecords<
WorkflowVersion & {
workflow: Omit<Workflow, 'versions'> & {
versions: Array<{ __typename: string }>;
};
}
Pick<WorkflowVersion, 'id' | '__typename'>
>({
objectNameSingular: CoreObjectNameSingular.WorkflowVersion,
filter: {
@@ -21,21 +23,6 @@ export const useActiveWorkflowVersion = (workflowId: string) => {
},
recordGqlFields: {
id: true,
name: true,
createdAt: true,
updatedAt: true,
workflowId: true,
trigger: true,
steps: true,
status: true,
workflow: {
id: true,
name: true,
statuses: true,
versions: {
totalCount: true,
},
},
},
});
@@ -1,8 +1,6 @@
import { isGlobalManualTrigger } from '@/action-menu/actions/record-actions/utils/isGlobalManualTrigger';
import { useObjectMetadataItem } from '@/object-metadata/hooks/useObjectMetadataItem';
import { CoreObjectNameSingular } from '@/object-metadata/types/CoreObjectNameSingular';
import { type ObjectMetadataItem } from '@/object-metadata/types/ObjectMetadataItem';
import { generateDepthOneRecordGqlFields } from '@/object-record/graphql/utils/generateDepthOneRecordGqlFields';
import { useFindManyRecords } from '@/object-record/hooks/useFindManyRecords';
import {
type ManualTriggerWorkflowVersion,
@@ -52,23 +50,24 @@ export const useActiveWorkflowVersionsWithManualTrigger = ({
filters.push(objectTypeFilter);
}
const { objectMetadataItem: workflowVersionObjectMetadataItem } =
useObjectMetadataItem({
objectNameSingular: CoreObjectNameSingular.WorkflowVersion,
});
const { records } = useFindManyRecords<
ManualTriggerWorkflowVersion & { workflow: Workflow }
Pick<
ManualTriggerWorkflowVersion,
'id' | '__typename' | 'trigger' | 'status' | 'workflowId'
> & {
workflow: Workflow;
}
>({
objectNameSingular: CoreObjectNameSingular.WorkflowVersion,
filter: {
and: filters,
},
recordGqlFields: {
...generateDepthOneRecordGqlFields({
objectMetadataItem: workflowVersionObjectMetadataItem,
}),
id: true,
trigger: true,
workflowId: true,
workflow: true,
status: true,
},
skip,
});