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