Skip to content

Commit d33bad2

Browse files
authored
Fix project status not being updated in neo4j with new workflow (#3249)
1 parent c45a8e2 commit d33bad2

File tree

2 files changed

+23
-8
lines changed

2 files changed

+23
-8
lines changed

src/components/project/project.repository.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -138,10 +138,7 @@ export class ProjectRepository extends CommonRepository {
138138
currentProject: UnsecuredDto<Project>,
139139
input: UpdateProject,
140140
) {
141-
return getChanges(IProject)(currentProject, {
142-
...input,
143-
...(input.step ? { status: stepToStatus(input.step) } : {}),
144-
});
141+
return getChanges(IProject)(currentProject, input);
145142
}
146143

147144
async create(input: CreateProject) {

src/components/project/workflow/project-workflow.neo4j.repository.ts

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import {
1111
requestingUser,
1212
sorting,
1313
} from '~/core/database/query';
14-
import { IProject, ProjectStep } from '../dto';
14+
import { IProject, ProjectStep, stepToStatus } from '../dto';
1515
import {
1616
ExecuteProjectTransitionInput,
1717
ProjectWorkflowEvent as WorkflowEvent,
@@ -67,11 +67,22 @@ export class ProjectWorkflowNeo4jRepository
6767
relation('out', undefined, 'who'),
6868
node('who', 'User'),
6969
])
70-
.return<{ dto: UnsecuredDto<WorkflowEvent> }>(
70+
.match([
71+
node('project'),
72+
relation('out', '', 'step', ACTIVE),
73+
node('step', 'Property'),
74+
])
75+
.return<{
76+
dto: UnsecuredDto<WorkflowEvent> & {
77+
project: { previousStep: ProjectStep };
78+
};
79+
}>(
7180
merge('node', {
7281
at: 'node.createdAt',
7382
who: 'who { .id }',
74-
project: 'project { .id, .type }',
83+
project: merge('project { .id, .type }', {
84+
previousStep: 'step.value',
85+
}),
7586
}).as('dto'),
7687
);
7788
}
@@ -100,10 +111,17 @@ export class ProjectWorkflowNeo4jRepository
100111
.first();
101112
const event = result!.dto;
102113

114+
const prevStatus = stepToStatus(event.project.previousStep);
115+
const nextStatus = stepToStatus(event.to);
116+
103117
await this.db.updateProperties({
104118
type: IProject,
105119
object: { id: project },
106-
changes: { step: event.to, stepChangedAt: event.at },
120+
changes: {
121+
step: event.to,
122+
stepChangedAt: event.at,
123+
status: prevStatus === nextStatus ? undefined : nextStatus,
124+
},
107125
permanentAfter: null,
108126
});
109127

0 commit comments

Comments
 (0)