refactor: rewrite useFlows as useConnectionFlows and useAppFlows with RQ

This commit is contained in:
Rıdvan Akca
2024-03-19 18:53:20 +03:00
parent ec87c7f21c
commit 316bda8c3f
8 changed files with 64 additions and 113 deletions

View File

@@ -1,40 +0,0 @@
import Flow from '../../models/flow.js';
import paginate from '../../helpers/pagination.js';
const getFlows = async (_parent, params, context) => {
const conditions = context.currentUser.can('read', 'Flow');
const userFlows = context.currentUser.$relatedQuery('flows');
const allFlows = Flow.query();
const baseQuery = conditions.isCreator ? userFlows : allFlows;
const flowsQuery = baseQuery
.clone()
.joinRelated({
steps: true,
})
.withGraphFetched({
steps: {
connection: true,
},
})
.where((builder) => {
if (params.connectionId) {
builder.where('steps.connection_id', params.connectionId);
}
if (params.name) {
builder.where('flows.name', 'ilike', `%${params.name}%`);
}
if (params.appKey) {
builder.where('steps.app_key', params.appKey);
}
})
.groupBy('flows.id')
.orderBy('active', 'desc')
.orderBy('updated_at', 'desc');
return paginate(flowsQuery, params.limit, params.offset);
};
export default getFlows;

View File

@@ -7,7 +7,6 @@ import getConnectedApps from './queries/get-connected-apps.js';
import getDynamicData from './queries/get-dynamic-data.js';
import getDynamicFields from './queries/get-dynamic-fields.js';
import getFlow from './queries/get-flow.js';
import getFlows from './queries/get-flows.js';
import getNotifications from './queries/get-notifications.js';
import getStepWithTestExecutions from './queries/get-step-with-test-executions.js';
import getUsers from './queries/get-users.js';
@@ -23,7 +22,6 @@ const queryResolvers = {
getDynamicData,
getDynamicFields,
getFlow,
getFlows,
getNotifications,
getStepWithTestExecutions,
getUsers,

View File

@@ -5,13 +5,6 @@ type Query {
getConnectedApps(name: String): [App]
testConnection(id: String!): Connection
getFlow(id: String!): Flow
getFlows(
limit: Int!
offset: Int!
appKey: String
connectionId: String
name: String
): FlowConnection
getStepWithTestExecutions(stepId: String!): [Step]
getDynamicData(
stepId: String!
@@ -257,15 +250,6 @@ type Field {
options: [SubstepArgumentOption]
}
type FlowConnection {
edges: [FlowEdge]
pageInfo: PageInfo
}
type FlowEdge {
node: Flow
}
enum FlowStatus {
paused
published