fix: clone base db queries

This commit is contained in:
Ali BARIN
2023-08-03 19:07:01 +00:00
parent e4e3356dc9
commit 7ca37c412e
11 changed files with 13 additions and 0 deletions

View File

@@ -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({

View File

@@ -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');

View File

@@ -23,6 +23,7 @@ const getDynamicData = async (
const stepBaseQuery = conditions.isCreator ? userSteps : allSteps;
const step = await stepBaseQuery
.clone()
.withGraphFetched({
connection: true,
flow: true,

View File

@@ -21,6 +21,7 @@ const getDynamicFields = async (
const stepBaseQuery = conditions.isCreator ? userSteps : allSteps;
const step = await stepBaseQuery
.clone()
.withGraphFetched({
connection: true,
flow: true,

View File

@@ -19,6 +19,7 @@ const getExecutionSteps = async (
const executionBaseQuery = conditions.isCreator ? userExecutions : allExecutions;
const execution = await executionBaseQuery
.clone()
.withSoftDeleted()
.findById(params.executionId)
.throwIfNotFound();

View File

@@ -16,6 +16,7 @@ const getExecution = async (
const executionBaseQuery = conditions.isCreator ? userExecutions : allExecutions;
const execution = await executionBaseQuery
.clone()
.withGraphFetched({
flow: {
steps: true,

View File

@@ -29,6 +29,7 @@ const getExecutions = async (
`;
const executions = executionBaseQuery
.clone()
.joinRelated('executionSteps as execution_steps')
.select('executions.*', raw(selectStatusStatement))
.withSoftDeleted()

View File

@@ -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 })

View File

@@ -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,
})

View File

@@ -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)

View File

@@ -19,6 +19,7 @@ const testConnection = async (
const connectionBaseQuery = conditions.isCreator ? userConnections : allConnections;
let connection = await connectionBaseQuery
.clone()
.findOne({
id: params.id,
})