From 4beaaaef91fb906075d6a2d1205bfdcbc3da0bba Mon Sep 17 00:00:00 2001 From: devanshu052000 Date: Sat, 24 May 2025 20:55:50 +0530 Subject: [PATCH] Added check for running query in the backend --- frontend/src/AppBuilder/_stores/slices/queryPanelSlice.js | 4 +++- frontend/src/_services/dataquery.service.js | 4 ++-- server/ee | 2 +- server/src/modules/data-queries/controller.ts | 6 ++++-- server/src/modules/data-queries/interfaces/IController.ts | 3 ++- server/src/modules/data-queries/interfaces/IService.ts | 3 ++- server/src/modules/data-queries/service.ts | 5 +++-- 7 files changed, 17 insertions(+), 10 deletions(-) diff --git a/frontend/src/AppBuilder/_stores/slices/queryPanelSlice.js b/frontend/src/AppBuilder/_stores/slices/queryPanelSlice.js index ddb67a5445..cd240a0c6d 100644 --- a/frontend/src/AppBuilder/_stores/slices/queryPanelSlice.js +++ b/frontend/src/AppBuilder/_stores/slices/queryPanelSlice.js @@ -215,6 +215,7 @@ export const createQueryPanelSlice = (set, get) => ({ selectedEnvironment, isPublicAccess, currentVersionId, + currentMode, } = get(); const { queryPreviewData, @@ -352,7 +353,8 @@ export const createQueryPanelSlice = (set, get) => ({ options, query?.options, currentVersionId, - !isPublicAccess ? (currentAppEnvironmentId ?? environmentId) || selectedEnvironment?.id : undefined //TODO: currentAppEnvironmentId may no longer required. Need to check + !isPublicAccess ? (currentAppEnvironmentId ?? environmentId) || selectedEnvironment?.id : undefined, //TODO: currentAppEnvironmentId may no longer required. Need to check + currentMode ); } diff --git a/frontend/src/_services/dataquery.service.js b/frontend/src/_services/dataquery.service.js index 36de55b907..3dc5e26593 100644 --- a/frontend/src/_services/dataquery.service.js +++ b/frontend/src/_services/dataquery.service.js @@ -72,7 +72,7 @@ function del(id, versionId) { return fetch(`${config.apiUrl}/data-queries/${id}/versions/${versionId}`, requestOptions).then(handleResponse); } -function run(queryId, resolvedOptions, options, versionId, environmentId) { +function run(queryId, resolvedOptions, options, versionId, environmentId, mode) { const body = { resolvedOptions: resolvedOptions, options: options, @@ -80,7 +80,7 @@ function run(queryId, resolvedOptions, options, versionId, environmentId) { let url = `${config.apiUrl}/data-queries/${queryId}/versions/${versionId}/run${ environmentId && environmentId !== 'undefined' ? `/${environmentId}` : '' - }`; + }?mode=${mode}`; //For public/released apps if (!environmentId || !versionId) { diff --git a/server/ee b/server/ee index 1b52eeeff5..648a1c9e79 160000 --- a/server/ee +++ b/server/ee @@ -1 +1 @@ -Subproject commit 1b52eeeff52a99ee910431b5644859f2622439b7 +Subproject commit 648a1c9e7959d7e47576bfc74645ac96200940af diff --git a/server/src/modules/data-queries/controller.ts b/server/src/modules/data-queries/controller.ts index 21f8df688f..e734810703 100644 --- a/server/src/modules/data-queries/controller.ts +++ b/server/src/modules/data-queries/controller.ts @@ -113,7 +113,8 @@ export class DataQueriesController implements IDataQueriesController { @Body() updateDataQueryDto: UpdateDataQueryDto, @Ability() ability: AppAbility, @DataSource() dataSource: DataSourceEntity, - @Res({ passthrough: true }) response: Response + @Res({ passthrough: true }) response: Response, + @Query('mode') mode?: string ) { return this.dataQueriesService.runQueryOnBuilder( user, @@ -122,7 +123,8 @@ export class DataQueriesController implements IDataQueriesController { updateDataQueryDto, ability, dataSource, - response + response, + mode ); } diff --git a/server/src/modules/data-queries/interfaces/IController.ts b/server/src/modules/data-queries/interfaces/IController.ts index 93024bca3e..59292772e2 100644 --- a/server/src/modules/data-queries/interfaces/IController.ts +++ b/server/src/modules/data-queries/interfaces/IController.ts @@ -36,7 +36,8 @@ export interface IDataQueriesController { updateDataQueryDto: UpdateDataQueryDto, ability: AppAbility, dataSource: DataSourceEntity, - response: Response + response: Response, + mode?: string ): Promise; runQuery( diff --git a/server/src/modules/data-queries/interfaces/IService.ts b/server/src/modules/data-queries/interfaces/IService.ts index a51ce642d2..08127d22ce 100644 --- a/server/src/modules/data-queries/interfaces/IService.ts +++ b/server/src/modules/data-queries/interfaces/IService.ts @@ -22,7 +22,8 @@ export interface IDataQueriesService { updateDataQueryDto: UpdateDataQueryDto, ability: object, dataSource: DataSource, - response: Response + response: Response, + mode?: string ): Promise; runQueryForApp( diff --git a/server/src/modules/data-queries/service.ts b/server/src/modules/data-queries/service.ts index 64bdd66c68..e8d5003a6d 100644 --- a/server/src/modules/data-queries/service.ts +++ b/server/src/modules/data-queries/service.ts @@ -127,7 +127,8 @@ export class DataQueriesService implements IDataQueriesService { updateDataQueryDto: UpdateDataQueryDto, ability: AppAbility, dataSource: DataSource, - response: Response + response: Response, + mode?: string ) { const { options, resolvedOptions } = updateDataQueryDto; @@ -153,7 +154,7 @@ export class DataQueriesService implements IDataQueriesService { return this.runAndGetResult(user, dataQuery, options, response, environmentId); } - private async runAndGetResult( + protected async runAndGetResult( user: User, dataQuery: DataQuery, resolvedOptions: object,