Skip to content

Commit 4690694

Browse files
authored
PLU-401: Deleted steps are removed from past executions (#850)
## Problem - When a step is deleted, the related execution steps are removed from the steps of past executions in the Executions tab. - Current query ignores execution steps that have been soft deleted (soft delete happens when user deletes a step in the Pipe editor) - Execution row app icons do not reflect the correct apps that were executed, only shows the current apps in the Pipe ## Solution - Query for all execution steps regardless of delete status to reflect the execution accurately. - Query and display the app keys for each execution ## Before & After Screenshots **BEFORE**: ![image](https://github.com/user-attachments/assets/d435722a-a43c-4ff2-95bb-b41f38c972db) ![image (1)](https://github.com/user-attachments/assets/f4065de4-0d6b-4078-a8d5-6da34fd89bec) <img width="1213" alt="Screenshot 2025-02-06 at 11 01 13 PM" src="https://github.com/user-attachments/assets/de6bb390-b3fb-4709-ae84-5056e937f38b" /> **AFTER**: ![Screenshot 2025-02-06 at 9 40 32 PM](https://github.com/user-attachments/assets/0f2ca52e-6795-4ebf-826d-f32a4a89598c) <img width="1512" alt="Screenshot 2025-02-06 at 9 41 06 PM" src="https://github.com/user-attachments/assets/04f0c526-dfa0-431c-9410-75f87fb05a61" /> <img width="1512" alt="Screenshot 2025-02-06 at 9 41 19 PM" src="https://github.com/user-attachments/assets/9bd148cd-8564-40c6-b61d-8e6d5e760ec5" /> ![Screenshot 2025-02-06 at 10 59 11 PM](https://github.com/user-attachments/assets/91c2df69-c899-4419-8d27-7e647a7b8355) ## Tests - [x] Existing pipes execute as usual - [x] Failed pipes show error as usual - [x] New executions follow the updated steps in the Pipe - [x] Past executions reflect the correct steps prior to the updates
1 parent eb7a053 commit 4690694

File tree

6 files changed

+36
-2
lines changed

6 files changed

+36
-2
lines changed

packages/backend/src/graphql/queries/get-execution-steps.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ const getExecutionSteps: QueryResolvers['getExecutionSteps'] = async (
2828
.from('execution_steps')
2929
.groupBy('step_id')
3030
.where('execution_id', '=', execution.id)
31+
.withSoftDeleted()
3132
})
3233
.join('latest_steps', (builder) => {
3334
builder

packages/backend/src/graphql/queries/get-executions.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,11 @@ const getExecutions: QueryResolvers['getExecutions'] = async (
2323

2424
const executionsQuery = context.currentUser
2525
.$relatedQuery('executions')
26+
.withGraphFetched({
27+
executionSteps: true,
28+
})
2629
.where(filterBuilder)
30+
.withSoftDeleted()
2731
.orderBy('created_at', 'desc')
2832

2933
return paginate(executionsQuery, params.limit, params.offset)

packages/backend/src/graphql/schema.graphql

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,7 @@ type ExecutionStep {
296296
stepId: String
297297
step: Step
298298
appKey: String
299+
iconUrl: String
299300
jobId: String
300301
status: String
301302
dataIn: JSONObject
@@ -380,6 +381,7 @@ type Execution {
380381
updatedAt: String
381382
status: String
382383
flow: Flow
384+
executionSteps: [ExecutionStep]
383385
}
384386

385387
type BulkRetryExecutionsResult {

packages/backend/src/models/execution-step.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import { IExecutionStepMetadata, IJSONObject } from '@plumber/types'
22

3+
import appConfig from '@/config/app'
4+
35
import Base from './base'
46
import Execution from './execution'
57
import Step from './step'
@@ -44,6 +46,10 @@ class ExecutionStep extends Base {
4446
},
4547
}
4648

49+
static get virtualAttributes() {
50+
return ['iconUrl']
51+
}
52+
4753
static relationMappings = () => ({
4854
execution: {
4955
relation: Base.BelongsToOneRelation,
@@ -66,6 +72,14 @@ class ExecutionStep extends Base {
6672
get isFailed() {
6773
return this.status === 'failure'
6874
}
75+
76+
get iconUrl() {
77+
if (!this.appKey) {
78+
return null
79+
}
80+
81+
return `${appConfig.baseUrl}/apps/${this.appKey}/assets/favicon.svg`
82+
}
6983
}
7084

7185
export default ExecutionStep

packages/frontend/src/components/ExecutionRow/index.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ type ExecutionRowProps = {
2727

2828
export default function ExecutionRow(props: ExecutionRowProps): ReactElement {
2929
const { execution } = props
30-
const { flow } = execution
30+
const { flow, executionSteps } = execution
3131

3232
const createdAt = DateTime.fromMillis(parseInt(execution.createdAt, 10))
3333
const relativeCreatedAt = createdAt.toRelative()
@@ -63,7 +63,12 @@ export default function ExecutionRow(props: ExecutionRowProps): ReactElement {
6363
>
6464
<GridItem area="apps">
6565
<HStack>
66-
<FlowAppIcons steps={flow.steps} />
66+
<FlowAppIcons
67+
// NOTE: passing executionSteps into steps props to preserve deleted steps
68+
steps={[...executionSteps].sort(
69+
(a, b) => Number(a.createdAt) - Number(b.createdAt),
70+
)}
71+
/>
6772
</HStack>
6873
</GridItem>
6974
<GridItem area="title">

packages/frontend/src/graphql/queries/get-executions.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,14 @@ export const GET_EXECUTIONS = gql`
2424
createdAt
2525
updatedAt
2626
status
27+
executionSteps {
28+
id
29+
appKey
30+
createdAt
31+
updatedAt
32+
status
33+
iconUrl
34+
}
2735
}
2836
}
2937
}

0 commit comments

Comments
 (0)