Skip to content

Commit

Permalink
feat: handle bypass_cache
Browse files Browse the repository at this point in the history
  • Loading branch information
tokebe committed May 9, 2024
1 parent e509fb7 commit 3d2c02c
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 15 deletions.
3 changes: 3 additions & 0 deletions packages/call-apis/src/queries/trapi_subquery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@ export default class TrapiSubquery extends Subquery {
queryBody.message.query_graph.edges.e01.qualifier_constraints =
qualifierConstraints;
}
if (this.options.caching === false) {
queryBody.bypass_cache = true;
}
const xmaturityMap = {
ci: "staging",
test: "test",
Expand Down
4 changes: 4 additions & 0 deletions packages/server/src/controllers/threading/threadHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,10 @@ export async function runTask(req: Request, res: Response, route: string, useBul
},
};

if ((req.body as TrapiQuery)?.bypass_cache) {
taskInfo.data.options.caching = false;
}

if (process.env.USE_THREADING === "false") {
// Threading disabled, just use the provided function in main event loop
const response = (await tasks[route](taskInfo)) as TrapiResponse;
Expand Down
13 changes: 8 additions & 5 deletions packages/server/src/routes/v1/asyncquery_v1.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,18 @@ class V1AsyncQuery implements BteRoute {
) => {
const queueData: QueueData = {
route: req.route.path,
queryGraph: req.body.message.query_graph,
workflow: req.body.workflow,
callback_url: req.body.callback,
queryGraph: req.body?.message.query_graph,
workflow: req.body?.workflow,
callback_url: req.body?.callback,
options: {
logLevel: req.body.log_level,
submitter: req.body.submitter,
logLevel: req.body?.log_level,
submitter: req.body?.submitter,
...req.query,
},
};
if (req.body?.bypass_cache) {
queueData.options.caching = false;
}
await asyncquery(req, res, next, queueData, global.queryQueue.bte_query_queue);
}) as RequestHandler)
.all(utils.methodNotAllowed);
Expand Down
13 changes: 8 additions & 5 deletions packages/server/src/routes/v1/asyncquery_v1_by_api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,19 @@ class V1AsyncQueryByAPI implements BteRoute {
.post(swaggerValidation.validate, async (req: Request, res: Response, next: NextFunction) => {
const queueData: QueueData = {
route: req.route.path,
queryGraph: req.body.message.query_graph,
queryGraph: req.body?.message.query_graph,
smartAPIID: req.params.smartapi_id,
workflow: req.body.workflow,
callback_url: req.body.callback,
workflow: req.body?.workflow,
callback_url: req.body?.callback,
options: {
logLevel: req.body.log_level,
submitter: req.body.submitter,
logLevel: req.body?.log_level,
submitter: req.body?.submitter,
...req.query,
},
};
if (req.body?.bypass_cache) {
queueData.options.caching = false;
}
await asyncquery(req, res, next, queueData, global.queryQueue["bte_query_queue_by_api"]);
})
.all(utils.methodNotAllowed);
Expand Down
13 changes: 8 additions & 5 deletions packages/server/src/routes/v1/asyncquery_v1_by_team.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,19 @@ class V1AsyncQueryByTeam implements BteRoute {
.post(swaggerValidation.validate, (async (req: Request, res: Response, next: NextFunction) => {
const queueData: QueueData = {
route: req.route.path,
queryGraph: req.body.message.query_graph,
queryGraph: req.body?.message.query_graph,
teamName: req.params.team_name,
workflow: req.body.workflow,
callback_url: req.body.callback,
workflow: req.body?.workflow,
callback_url: req.body?.callback,
options: {
logLevel: req.body.log_level,
submitter: req.body.submitter,
logLevel: req.body?.log_level,
submitter: req.body?.submitter,
...req.query,
},
};
if (req.body?.bypass_cache) {
queueData.options.caching = false;
}
await asyncquery(req, res, next, queueData, global.queryQueue["bte_query_queue_by_team"]);
}) as RequestHandler)
.all(utils.methodNotAllowed);
Expand Down
1 change: 1 addition & 0 deletions packages/types/src/trapi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ export interface TrapiResponseMessage {
}

export interface TrapiQuery {
bypass_cache?: boolean;
message: TrapiQueryMessage;
log_level?: string;
workflow?: TrapiWorkflow[];
Expand Down

0 comments on commit 3d2c02c

Please sign in to comment.