Skip to content

Commit

Permalink
fix(api-elasticsearch-tasks): possibility to pass the limit through t…
Browse files Browse the repository at this point in the history
…ask input (#3886)
  • Loading branch information
brunozoric authored Feb 21, 2024
1 parent 61cb130 commit 50b80c7
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export class ReindexingTaskRunner {
*/
public async exec(
keys: IElasticsearchIndexingTaskValuesKeys | undefined = undefined,
limit = 200
limit: number
): Promise<ITaskResponseResult> {
this.keys = keys;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export const createElasticsearchReindexingTask = (params?: IElasticsearchTaskCon
const reindexing = new ReindexingTaskRunner(manager, indexManager);

const keys = input.keys || undefined;
return reindexing.exec(keys, 200);
return reindexing.exec(keys, input.limit || 100);
}
});
};
1 change: 1 addition & 0 deletions packages/api-elasticsearch-tasks/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export interface IElasticsearchIndexingTaskValuesSettings {

export interface IElasticsearchIndexingTaskValues {
matching?: string;
limit?: number;
keys?: IElasticsearchIndexingTaskValuesKeys;
settings?: IElasticsearchIndexingTaskValuesSettings;
}
Expand Down
4 changes: 2 additions & 2 deletions packages/handler/src/fastify.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import {
ContextRoutes,
DefinedContextRoutes,
HTTPMethods,
Request,
Reply,
Request,
RouteMethodOptions
} from "~/types";
import { Context } from "~/Context";
Expand Down Expand Up @@ -186,7 +186,7 @@ export const createHandler = (params: CreateHandlerParams) => {
* We must attach the server to our internal context if we want to have it accessible.
*/
const app = fastify({
bodyLimit: 10485760, // 10MB
bodyLimit: 536870912, // 512MB
...(params.options || {})
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ export const handler = createHandler({
createEventHandler()
],
options: {
bodyLimit: 536870912
bodyLimit: 536870912 // 512MB
}
});
22 changes: 20 additions & 2 deletions packages/tasks/__tests__/graphql/tasks.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ describe("graphql - tasks", () => {
it("should list tasks", async () => {
const context = await contextHandler.handle();

await context.tasks.createTask({
const task = await context.tasks.createTask({
name: "My Custom Task #1",
definitionId: "myCustomTaskNumber1",
input: {
Expand All @@ -42,6 +42,11 @@ describe("graphql - tasks", () => {
}
});

await context.tasks.createLog(task, {
executionName: task.executionName || "mock execution name",
iteration: 1
});

const response = await handler.listTasks();

expect(response).toEqual({
Expand Down Expand Up @@ -98,7 +103,20 @@ describe("graphql - tasks", () => {
createdOn: expect.any(String),
savedOn: expect.any(String),
eventResponse: null,
logs: []
logs: [
{
createdBy: {
displayName: "John Doe",
id: "id-12345678",
type: "admin"
},
createdOn: expect.toBeDateString(),
executionName: "mock execution name",
id: expect.any(String),
items: [],
iteration: 1
}
]
}
],
meta: {
Expand Down

0 comments on commit 50b80c7

Please sign in to comment.