Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
gavinhenderson committed Nov 17, 2023
1 parent 3626a97 commit a54d02e
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions lib/products/get-all-categories.js
Original file line number Diff line number Diff line change
Expand Up @@ -202,13 +202,11 @@ export const parseCategories = (catetoryNodes, getMeta = getProductsMeta) => {
.filter((node) => node.slug !== "uncategorised");
};

const getProductsMeta = (products, topLevel) => {
const allChildrenProducts = topLevel.children.nodes.flatMap(
(x) => x.products.nodes
);
const allProducts = [...products.nodes, ...allChildrenProducts];
const getProductsMeta = (products) => {
if (!products) return 0;
if (!products.nodes) return 0;

const nonMoodleCourses = allProducts.filter((node) => {
const nonMoodleCourses = products.nodes.filter((node) => {
if (!node.moodleCourses) return true;
if (!node.moodleCourses.nodes) return true;
if (node.moodleCourses.nodes.length === 0) return true;
Expand Down

0 comments on commit a54d02e

Please sign in to comment.