Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: sonar duplication #397

Merged
merged 15 commits into from
Dec 17, 2024
Merged

fix: sonar duplication #397

merged 15 commits into from
Dec 17, 2024

Conversation

JBR90
Copy link
Contributor

@JBR90 JBR90 commented Nov 27, 2024

Description

  • Removes test files from duplication coverage
  • Focuses on reducing duplication in the exports package and route

Sonar is failing on this PR but after merge this brings the overall duplication on main down to 2%, some of the exports files were 100% duplication.

How to test

  1. Go to https://oak-ai-lesson-assistant-6hlwvbq0o.vercel-preview.thenational.academy
    Exports and downloads / downloads all should all work as they did before

Checklist

  • Manually tested across browsers / devices
  • Considered impact on accessibility
  • Does this PR update a package with a breaking change

Copy link

vercel bot commented Nov 27, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
oak-ai-lesson-assistant ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 12, 2024 0:09am

@stefl stefl changed the title Fix/sonar duplication fix: sonar duplication Nov 27, 2024
Copy link

github-actions bot commented Nov 28, 2024

Playwright test results

passed  15 passed
skipped  1 skipped

Details

report  Open report ↗︎
stats  16 tests across 15 suites
duration  2 minutes, 11 seconds
commit  926b8e0

Skipped tests

No persona › tests/auth.test.ts › authenticate through Clerk UI

@JBR90 JBR90 requested review from mikeritson-oak and a team November 28, 2024 11:08
@JBR90 JBR90 marked this pull request as ready for review November 28, 2024 11:10
Copy link
Contributor

@stefl stefl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks much neater! A couple of minor points but could be follow-ups

return userEmail;
};

const categoryMap: Record<string, string> = {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Worth exporting this for tests?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is exporting usefull for tests ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can import the list of categories in the test file. I'm generally exporting types wherever they are defined so that when we have tests we can share the types in the test files

@@ -22,7 +16,7 @@ export async function exportLessonPlan({
ctx,
}: {
input: {
data: LessonSlidesInputData;
data: LessonSlidesInputData; // should this be lesson plan
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need input from Tom / Matt here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have changed correct type

prisma: ctx.prisma,
snapshotId,
exportType: "LESSON_SLIDES_SLIDES",
const exportType = "LESSON_SLIDES_SLIDES";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This does looks like a typo in the original code

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

enum LessonExportType {
  STARTER_QUIZ_DOC
  EXIT_QUIZ_DOC
  LESSON_PLAN_DOC
  LESSON_SLIDES_SLIDES
  WORKSHEET_SLIDES
  ADDITIONAL_MATERIALS_DOCS

  @@schema("public")
}

Seems like it is the correct name

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd expect it to be LESSON_PLAN_SLIDES rather than LESSON_SLIDES_SLIDES - reads like a typo. Not suggesting this is a new code issue, but presumably this is hard to change if it's a database enum

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah for sure, was surprised when i saw it

}),
}),
}),
programme: Programme,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For Zod Schemas I normally have ProgrammeSchema for the zod schema and then Programme for the type. Should we adopt that here or is this schema already named Programme?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The schema Programme already existed

Copy link
Collaborator

@mikeritson-oak mikeritson-oak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generally looked OK but I did get a couple of instances of error messages when attempting to download resources. They weren't persistent errors, they came and went across lesson.

Example lesson ID: 4ISp1rBzC_p-VAdT
Example lesson ID: z1YcdmVh1MoMOv57

SCR-20241128-nzwu
SCR-20241128-nztl

Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
3.7% Duplication on New Code (required ≤ 3%)

See analysis details on SonarQube Cloud

Copy link
Collaborator

@mikeritson-oak mikeritson-oak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Following the review, @JBR90 was unable to replicate the problems I had seen. I had another check and also didn't see the original problem. Joe has now brought this branch up-to-date with main and I've rechecked, no issues seen. I'm assuming that the original issue seen with downloads was a temporary issue or nothing to do with this work and has since been resolved. Looks good now. 👍

@JBR90 JBR90 merged commit dea3106 into main Dec 17, 2024
19 of 21 checks passed
@JBR90 JBR90 deleted the fix/sonar-duplication branch December 17, 2024 08:48
@oak-machine-user
Copy link
Collaborator

🎉 This PR is included in version 1.19.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants