Refactor: Morph strategy on PipelineProgress (#1065)

* Deprecate pipelineprogress backref on person to improve naming

* Remove deprecated point of contact fields

* Add company and person entities on pipelineprogress

* Migrate data from old progressable to new entity fields

* Codegen frontend

* Use company Id, deprecate progressableId

* Get rid of deprecated progressableId field

* Remove deprecated progressableType field from pipeline progress

* Remove useless migrations
This commit is contained in:
Emilien Chauvet
2023-08-03 18:08:35 +02:00
committed by GitHub
parent 4252a0a2c3
commit 21e3d8fcac
15 changed files with 327 additions and 263 deletions

View File

@ -119,7 +119,7 @@ export function HooksCompanyBoard({
variables: {
where: {
id: {
in: pipelineProgresses.map((item) => item.progressableId),
in: pipelineProgresses.map((item) => item.companyId || ''),
},
},
},
@ -145,7 +145,9 @@ export function HooksCompanyBoard({
},
pipelineProgress: PipelineProgressForBoard,
) => {
const company = companiesDict[pipelineProgress.progressableId];
const company =
pipelineProgress.companyId && companiesDict[pipelineProgress.companyId];
if (!company) return acc;
return {
...acc,
[pipelineProgress.id]: {

View File

@ -15,10 +15,7 @@ import { relationPickerSearchFilterScopedState } from '@/ui/input/relation-picke
import { RelationPickerHotkeyScope } from '@/ui/input/relation-picker/types/RelationPickerHotkeyScope';
import { usePreviousHotkeyScope } from '@/ui/utilities/hotkey/hooks/usePreviousHotkeyScope';
import { useRecoilScopedState } from '@/ui/utilities/recoil-scope/hooks/useRecoilScopedState';
import {
PipelineProgressableType,
useCreateOnePipelineProgressMutation,
} from '~/generated/graphql';
import { useCreateOneCompanyPipelineProgressMutation } from '~/generated/graphql';
import { useFilteredSearchCompanyQuery } from '../queries';
@ -36,12 +33,13 @@ export function NewCompanyProgressButton() {
setHotkeyScopeAndMemorizePreviousScope,
} = usePreviousHotkeyScope();
const [createOnePipelineProgress] = useCreateOnePipelineProgressMutation({
refetchQueries: [
getOperationName(GET_PIPELINE_PROGRESS) ?? '',
getOperationName(GET_PIPELINES) ?? '',
],
});
const [createOneCompanyPipelineProgress] =
useCreateOneCompanyPipelineProgressMutation({
refetchQueries: [
getOperationName(GET_PIPELINE_PROGRESS) ?? '',
getOperationName(GET_PIPELINES) ?? '',
],
});
const handleEntitySelect = useCallback(
async (company: any) => {
@ -58,13 +56,12 @@ export function NewCompanyProgressButton() {
);
newBoard[destinationColumnIndex].pipelineProgressIds.push(newUuid);
setBoard(newBoard);
await createOnePipelineProgress({
await createOneCompanyPipelineProgress({
variables: {
uuid: newUuid,
pipelineStageId: pipelineStageId || '',
pipelineId: pipeline?.id || '',
entityId: company.id || '',
entityType: PipelineProgressableType.Company,
companyId: company.id || '',
},
});
},
@ -72,7 +69,7 @@ export function NewCompanyProgressButton() {
goBackToPreviousHotkeyScope,
board,
setBoard,
createOnePipelineProgress,
createOneCompanyPipelineProgress,
pipelineStageId,
pipeline?.id,
],