-
Notifications
You must be signed in to change notification settings - Fork 617
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(api-headless-cms-bulk-actions): fix task execution for large entr…
…ies list (#4283) Co-authored-by: Bruno Zorić <[email protected]>
- Loading branch information
1 parent
af4195f
commit 4e1127e
Showing
38 changed files
with
463 additions
and
138 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,10 @@ | ||
import { createTasks } from "~/tasks"; | ||
import { createHandlers } from "~/handlers"; | ||
import { createDefaultGraphQL } from "~/plugins"; | ||
|
||
export * from "./abstractions"; | ||
export * from "./handlers"; | ||
export * from "./useCases"; | ||
export * from "./plugins"; | ||
export * from "./tasks"; | ||
|
||
export const createHcmsBulkActions = () => [ | ||
createTasks(), | ||
createHandlers(), | ||
createDefaultGraphQL() | ||
]; | ||
export const createHcmsBulkActions = () => [createHandlers(), createDefaultGraphQL()]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,2 @@ | ||
import { createBulkActionEntriesTasks } from "./createBulkActionEntriesTasks"; | ||
import { createEmptyTrashBinsTask } from "./createEmptyTrashBinsTask"; | ||
|
||
export const createTasks = () => { | ||
return [createBulkActionEntriesTasks(), createEmptyTrashBinsTask()]; | ||
}; | ||
export * from "./createBulkActionEntriesTasks"; | ||
export * from "./createEmptyTrashBinsTask"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
packages/api-headless-cms-bulk-actions/src/useCases/ListNotPublishedEntries.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { CmsEntryListParams } from "@webiny/api-headless-cms/types"; | ||
import { IListEntries } from "~/abstractions"; | ||
import { HcmsBulkActionsContext } from "~/types"; | ||
|
||
class ListNotPublishedEntries implements IListEntries { | ||
private readonly context: HcmsBulkActionsContext; | ||
|
||
constructor(context: HcmsBulkActionsContext) { | ||
this.context = context; | ||
} | ||
|
||
async execute(modelId: string, params: CmsEntryListParams) { | ||
const model = await this.context.cms.getModel(modelId); | ||
|
||
if (!model) { | ||
throw new Error(`Model with ${modelId} not found!`); | ||
} | ||
|
||
const [entries, meta] = await this.context.cms.listLatestEntries(model, { | ||
...params, | ||
where: { | ||
...params.where, | ||
status_not: "published" | ||
} | ||
}); | ||
|
||
return { | ||
entries, | ||
meta | ||
}; | ||
} | ||
} | ||
|
||
export const createListNotPublishedEntries = (context: HcmsBulkActionsContext) => { | ||
return new ListNotPublishedEntries(context); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.