fix: clone base db queries
This commit is contained in:
@@ -17,6 +17,7 @@ const getApp = async (_parent: unknown, params: Params, context: Context) => {
|
||||
|
||||
if (context.currentUser) {
|
||||
const connections = await connectionBaseQuery
|
||||
.clone()
|
||||
.select('connections.*')
|
||||
.fullOuterJoinRelated('steps')
|
||||
.where({
|
||||
|
@@ -26,12 +26,14 @@ const getConnectedApps = async (
|
||||
let apps = await App.findAll(params.name);
|
||||
|
||||
const connections = await connectionBaseQuery
|
||||
.clone()
|
||||
.select('connections.key')
|
||||
.where({ draft: false })
|
||||
.count('connections.id as count')
|
||||
.groupBy('connections.key');
|
||||
|
||||
const flows = await flowBaseQuery
|
||||
.clone()
|
||||
.withGraphJoined('steps')
|
||||
.orderBy('created_at', 'desc');
|
||||
|
||||
|
@@ -23,6 +23,7 @@ const getDynamicData = async (
|
||||
const stepBaseQuery = conditions.isCreator ? userSteps : allSteps;
|
||||
|
||||
const step = await stepBaseQuery
|
||||
.clone()
|
||||
.withGraphFetched({
|
||||
connection: true,
|
||||
flow: true,
|
||||
|
@@ -21,6 +21,7 @@ const getDynamicFields = async (
|
||||
const stepBaseQuery = conditions.isCreator ? userSteps : allSteps;
|
||||
|
||||
const step = await stepBaseQuery
|
||||
.clone()
|
||||
.withGraphFetched({
|
||||
connection: true,
|
||||
flow: true,
|
||||
|
@@ -19,6 +19,7 @@ const getExecutionSteps = async (
|
||||
const executionBaseQuery = conditions.isCreator ? userExecutions : allExecutions;
|
||||
|
||||
const execution = await executionBaseQuery
|
||||
.clone()
|
||||
.withSoftDeleted()
|
||||
.findById(params.executionId)
|
||||
.throwIfNotFound();
|
||||
|
@@ -16,6 +16,7 @@ const getExecution = async (
|
||||
const executionBaseQuery = conditions.isCreator ? userExecutions : allExecutions;
|
||||
|
||||
const execution = await executionBaseQuery
|
||||
.clone()
|
||||
.withGraphFetched({
|
||||
flow: {
|
||||
steps: true,
|
||||
|
@@ -29,6 +29,7 @@ const getExecutions = async (
|
||||
`;
|
||||
|
||||
const executions = executionBaseQuery
|
||||
.clone()
|
||||
.joinRelated('executionSteps as execution_steps')
|
||||
.select('executions.*', raw(selectStatusStatement))
|
||||
.withSoftDeleted()
|
||||
|
@@ -12,6 +12,7 @@ const getFlow = async (_parent: unknown, params: Params, context: Context) => {
|
||||
const baseQuery = conditions.isCreator ? userFlows : allFlows;
|
||||
|
||||
const flow = await baseQuery
|
||||
.clone()
|
||||
.withGraphJoined('[steps.[connection]]')
|
||||
.orderBy('steps.position', 'asc')
|
||||
.findOne({ 'flows.id': params.id })
|
||||
|
@@ -17,6 +17,7 @@ const getFlows = async (_parent: unknown, params: Params, context: Context) => {
|
||||
const baseQuery = conditions.isCreator ? userFlows : allFlows;
|
||||
|
||||
const flowsQuery = baseQuery
|
||||
.clone()
|
||||
.joinRelated({
|
||||
steps: true,
|
||||
})
|
||||
|
@@ -18,10 +18,12 @@ const getStepWithTestExecutions = async (
|
||||
const stepBaseQuery = conditions.isCreator ? userSteps : allSteps;
|
||||
|
||||
const step = await stepBaseQuery
|
||||
.clone()
|
||||
.findOne({ 'steps.id': params.stepId })
|
||||
.throwIfNotFound();
|
||||
|
||||
const previousStepsWithCurrentStep = await stepBaseQuery
|
||||
.clone()
|
||||
.withGraphJoined('executionSteps')
|
||||
.where('flow_id', '=', step.flowId)
|
||||
.andWhere('position', '<', step.position)
|
||||
|
@@ -19,6 +19,7 @@ const testConnection = async (
|
||||
const connectionBaseQuery = conditions.isCreator ? userConnections : allConnections;
|
||||
|
||||
let connection = await connectionBaseQuery
|
||||
.clone()
|
||||
.findOne({
|
||||
id: params.id,
|
||||
})
|
||||
|
Reference in New Issue
Block a user