Skip to content

Commit

Permalink
feat(orchestrator): introduced workflows/:workflowId/overview endpo…
Browse files Browse the repository at this point in the history
…int (janus-idp#40)

* FLPATH-702 : New endpoint to fetch workflow overview

* FLPATH-702 : iterate through all elements instead of picking the first element

* modified the map method

* calculate avg execution time change

* Add log message when http calls failing

* Fix lint issues

* rename variable

* paginated graphql object fetch

* Include workflowId in the result object

* Renamed to description

* to epoc timestamp

* suppress eslint warning

* epoc number to string

* make all string fields optional

* use a simple for loop

* extracted to a new method

* rename to lastTriggeredMs

* include uri in the WorkflowOverview type

* mark avgDurationMs as optional

* fetch only one overview obj

* fix(orchestrator): make the port config optional (janus-idp#37)

* feat(orchestrator): orchestrator plugin entry page & workflows table (janus-idp#31)

https://issues.redhat.com/browse/FLPATH-686
https://issues.redhat.com/browse/FLPATH-682

* removed unnecessary method

---------

Co-authored-by: Guilherme Caponetto <[email protected]>
Co-authored-by: Jonathan Kilzi <[email protected]>
  • Loading branch information
3 people authored Nov 29, 2023
1 parent 9b2a2b9 commit 8549dd8
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
6 changes: 3 additions & 3 deletions plugins/orchestrator-backend/src/service/SonataFlowService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ export class SonataFlowService {
}
const items = await Promise.all(
workflowIds.map(async (workflowId: string) => {
return this.getWorkflowOverview(workflowId);
return this.fetchWorkflowOverview(workflowId);
}),
);
return items.filter((item): item is WorkflowOverview => !!item);
Expand All @@ -227,7 +227,7 @@ export class SonataFlowService {
);
} catch (error) {
this.logger.error(
`Error when fetching workflows for workflowoverview: ${error}`,
`Error when fetching workflows for workflowOverview: ${error}`,
);
}
return undefined;
Expand Down Expand Up @@ -472,7 +472,7 @@ export class SonataFlowService {
};
}

private async getWorkflowOverview(
public async fetchWorkflowOverview(
workflowId: string,
): Promise<WorkflowOverview | undefined> {
const definition = await this.fetchWorkflowDefinition(workflowId);
Expand Down
16 changes: 16 additions & 0 deletions plugins/orchestrator-backend/src/service/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,22 @@ function setupInternalRoutes(
res.status(200).json(executionResponse);
});

router.get('/workflows/:workflowId/overview', async (req, res) => {
const {
params: { workflowId },
} = req;
const overviewObj =
await sonataFlowService.fetchWorkflowOverview(workflowId);

if (!overviewObj) {
res
.status(500)
.send(`Couldn't fetch workflow overview for ${workflowId}`);
return;
}
res.status(200).json(overviewObj);
});

router.get('/instances', async (_, res) => {
const instances = await sonataFlowService.fetchProcessInstances();

Expand Down

0 comments on commit 8549dd8

Please sign in to comment.