Skip to content

Commit

Permalink
fix(main): merge main in
Browse files Browse the repository at this point in the history
  • Loading branch information
Ben Protheroe authored and Ben Protheroe committed May 12, 2023
2 parents 998b406 + 8776cd3 commit 7f3a8d5
Show file tree
Hide file tree
Showing 6 changed files with 78 additions and 48 deletions.
15 changes: 15 additions & 0 deletions CHANGE_LOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
## [1.181.2](https://github.com/oaknational/Oak-Web-Application/compare/v1.181.1...v1.181.2) (2023-05-11)


### Bug Fixes

* add no theme into learning themes ([e6b3ff1](https://github.com/oaknational/Oak-Web-Application/commit/e6b3ff153b74987904359aa35347d641227a5e39))
* type errors ([c02c502](https://github.com/oaknational/Oak-Web-Application/commit/c02c502d5c1bc51f57042144a9462da575037e52))

## [1.181.1](https://github.com/oaknational/Oak-Web-Application/compare/v1.181.0...v1.181.1) (2023-05-11)


### Bug Fixes

* **security policy:** meet formatting standard ([be40d8d](https://github.com/oaknational/Oak-Web-Application/commit/be40d8d44110af4c398705c4a36d580d9e2feb50))

# [1.181.0](https://github.com/oaknational/Oak-Web-Application/compare/v1.180.3...v1.181.0) (2023-05-11)


Expand Down
29 changes: 15 additions & 14 deletions public/.well-known/security.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ Hash: SHA256

# Please report any security vulnerabilities to us via the contact method(s) below, only after reading our security disclosure policy.
Contact: mailto:security@thenational.academy
Contact: https://docs.github.com/en/code-security/security-advisories/guidance-on-reporting-and-writing/privately-reporting-a-security-vulnerability
Preferred-Languages: en

# Encrypt your messages to Oak National Academy using the PGP key below
Expand All @@ -29,17 +30,17 @@ Hiring: https://jobs.thenational.academy
# Please see https://securitytxt.org/ for details of the specification of this file
-----BEGIN PGP SIGNATURE-----

iQIzBAEBCAAdFiEE6SUFh2S/HgValc+nlx8GIFG2C30FAmPihxMACgkQlx8GIFG2
C31pAA//ds+Ytm1eqGx0a5PlrKdpajAr3H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DXBSGqP5UKUgJ
blsEp+Z6RPeQkjEZnTHBBxcOepx7XdeGtGtiJqcuBNglmZ3hJuDAzjf696IBLryz
6F5EBLCGGJCNK4Uonzc5jYIjcMdXzA9bHvcz+R4+VvzasAsk8SSTThThdtysQ5Do
cUoxOEU0fSbTW1VZ73g1+otILluXBA7ghTvKJyHCUi42ZmxneNLJqLjERZ7lmJLk
hgnhOLQ9f7WgMqD4LkxIaV1Tb8j/frxbd2JrQR8Ht3oUe5mfTWV8Oku8BsUJ5GhN
XuV3a9148NKBHtnB9pJsgqVo8TLGa8c7fQFaXOAQ68+GCYp/Dmy17sX9lTyruZIy
dJMGcpZ2HlP0LFQn1BBaNGDwKY44LFHnnNrTOZ12nrtLlDp3lNc=
=v60q
-----END PGP SIGNATURE-----
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ export type LearningThemeSelectedTrackingProps = {
};

export type LearningTheme = {
learningThemeSlug?: string;
learningThemeTitle?: string;
learningThemeSlug?: string | null;
learningThemeTitle?: string | null;
};

export type LearningThemeFiltersProps = {
Expand Down Expand Up @@ -48,12 +48,12 @@ const LearningThemeFilters = ({
.sort(
(
a: {
label: string | undefined;
slug: string | undefined;
label: string | undefined | null;
slug: string | undefined | null;
},
b: {
label: string | undefined;
slug: string | undefined;
label: string | undefined | null;
slug: string | undefined | null;
}
) => {
if (a?.slug === "no-theme") {
Expand Down
13 changes: 12 additions & 1 deletion src/node-lib/curriculum-api/fixtures/unitListing.fixture.ts
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,18 @@ const unitListingFixture = (
expiredLessonCount: 0,
},
],
learningThemes: [],
learningThemes: [
{
learningThemeTitle: "The Canterbury Tales and paired texts",
learningThemeSlug: "the-canterbury-tales-and-paired-texts-39",
},
{
learningThemeTitle: "The sonnet through time",
learningThemeSlug: "the-sonnet-through-time-24",
},

{ learningThemeTitle: null, learningThemeSlug: "no-theme" },
],
...partial,
};
};
Expand Down
11 changes: 11 additions & 0 deletions src/node-lib/curriculum-api/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,17 @@ describe("curriculum-api", () => {
programmeSlug: "maths-secondary-ks4",
});
});
test("unitListing learningThemes contains 'no themes'", async () => {
const units = await curriculumApi.unitListing({
programmeSlug: "maths-secondary-ks4",
});
const hasThemes =
units.learningThemes?.filter(
(theme) => theme.learningThemeSlug === "no-theme"
).length > 0;

expect(hasThemes).toBe(true);
});
test("lessonListingPaths", async () => {
await curriculumApi.lessonListingPaths();
expect(lessonListingPaths).toHaveBeenCalled();
Expand Down
46 changes: 19 additions & 27 deletions src/node-lib/curriculum-api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -316,8 +316,8 @@ const unitListingData = z.object({
units: unitsData,
learningThemes: z.array(
z.object({
learningThemeTitle: z.string(),
learningThemeSlug: z.string(),
learningThemeTitle: z.string().nullable(),
learningThemeSlug: z.string().nullable(),
})
),
});
Expand Down Expand Up @@ -419,34 +419,26 @@ const curriculumApi = {
const { units = [], programmes = [], tiers = [] } = transformMVCase(res);

const programme = getFirstResultOrWarnOrFail()({ results: programmes });
const learningThemes = units
?.filter((unit) => unit?.themeSlug !== "no-theme")
.map((unitWithTheme) => ({
learningThemeSlug: unitWithTheme?.themeSlug || "",
learningThemeTitle: unitWithTheme?.themeTitle || "",
}))
.sort((a, b) => {
if (a.learningThemeTitle < b.learningThemeTitle) {
return -1;
}
if (a.learningThemeTitle > b.learningThemeTitle) {
return 1;
}
return 0;
});
const learningThemes = units.map((unitWithTheme) => ({
learningThemeSlug: unitWithTheme?.themeSlug,
learningThemeTitle: unitWithTheme?.themeTitle || "No theme",
}));

// !Refactor index signature to be more specific

type LearningTheme = {
[key: string]: string;
};

const filteredDuplicatedLearningThemes = learningThemes.filter(
(learningTheme: LearningTheme, index, learningThemeToCompare) =>
learningThemeToCompare.findIndex((lt: LearningTheme) =>
["learningThemeSlug"].every((l) => lt[l] === learningTheme[l])
) === index
);
const filteredDuplicatedLearningThemes = [
...new Map(
learningThemes.map((theme) => [JSON.stringify(theme), theme])
).values(),
].sort((a, b) => {
if (a.learningThemeTitle < b.learningThemeTitle) {
return -1;
}
if (a.learningThemeTitle > b.learningThemeTitle) {
return 1;
}
return 0;
});

return unitListingData.parse({
programmeSlug: programme?.programmeSlug,
Expand Down

0 comments on commit 7f3a8d5

Please sign in to comment.