Skip to content

Commit

Permalink
Merge branch 'dev' of github.com:webiny/webiny-js into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
Pavel910 committed Nov 23, 2023
2 parents ae017c2 + d3f5ef1 commit f038466
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export interface CreatePageTemplateStorageOperationsParams {
entity: Entity<any>;
plugins: PluginsContainer;
}

export const createPageTemplateStorageOperations = ({
entity,
plugins
Expand Down Expand Up @@ -95,27 +96,29 @@ export const createPageTemplateStorageOperations = ({
);
}

const itemsData = items.map(item => item?.data).filter(Boolean);

const fields = plugins.byType<PageTemplateDynamoDbElasticFieldPlugin>(
PageTemplateDynamoDbElasticFieldPlugin.type
);

const filteredItems = filterItems<DataContainer<PageTemplate>>({
const filteredItems = filterItems<PageTemplate>({
plugins,
where: restWhere,
items,
items: itemsData,
fields
});

const sortedItems = sortItems<DataContainer<PageTemplate>>({
const sortedItems = sortItems<PageTemplate>({
items: filteredItems,
sort,
fields
});

return createListResponse({
items: sortedItems.map(item => item?.data).filter(Boolean),
items: sortedItems,
limit: limit || 100000,
totalCount: filteredItems.length,
totalCount: sortedItems.length,
after: null
});
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export interface CreatePageTemplateStorageOperationsParams {
entity: Entity<any>;
plugins: PluginsContainer;
}

export const createPageTemplateStorageOperations = ({
entity,
plugins
Expand Down Expand Up @@ -95,27 +96,29 @@ export const createPageTemplateStorageOperations = ({
);
}

const itemsData = items.map(item => item?.data).filter(Boolean);

const fields = plugins.byType<PageTemplateDynamoDbFieldPlugin>(
PageTemplateDynamoDbFieldPlugin.type
);

const filteredItems = filterItems<DataContainer<PageTemplate>>({
const filteredItems = filterItems<PageTemplate>({
plugins,
where: restWhere,
items,
items: itemsData,
fields
});

const sortedItems = sortItems<DataContainer<PageTemplate>>({
const sortedItems = sortItems<PageTemplate>({
items: filteredItems,
sort,
fields
});

return createListResponse({
items: sortedItems.map(item => item?.data).filter(Boolean),
items: sortedItems,
limit: limit || 100000,
totalCount: filteredItems.length,
totalCount: sortedItems.length,
after: null
});
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ export const createPageTemplatesCrud = (
tenant: getTenantId(),
locale: getLocaleCode()
},
sort: Array.isArray(sort) && sort.length > 0 ? sort : ["createdOn_ASC"]
sort: Array.isArray(sort) && sort.length > 0 ? sort : ["createdOn_DESC"]
};

// If user can only manage own records, let's add that to the listing.
Expand Down

0 comments on commit f038466

Please sign in to comment.