Skip to content

Refactor courses to course#1732

Open
AngelsandDevsLOL wants to merge 5 commits into
Courseography:masterfrom
AngelsandDevsLOL:refactor-courses-to-course
Open

Refactor courses to course#1732
AngelsandDevsLOL wants to merge 5 commits into
Courseography:masterfrom
AngelsandDevsLOL:refactor-courses-to-course

Conversation

@AngelsandDevsLOL

@AngelsandDevsLOL AngelsandDevsLOL commented Jun 14, 2026

Copy link
Copy Markdown
Contributor

Proposed Changes

Building off the previous PR #1721 (which renamed the Course data type to CourseData and moved it into Models/Course.hs), this PR renames the Courses database table to Course. It adds a v3 migration to Database/Migrations.hs so the existing database table is renamed. It updates the Courses datatype in Database/Tables.hs to be Course, as well as updating all of the accessor functions from coursesX to courseX.

With the Course name now free from the previous PR, renaming the Courses table to Course makes the schema consistent with the rest of the table names and naming conventions.
...

Screenshots of your changes (if applicable)

Type of Change

(Write an X or a brief description next to the type or types that best describe your changes.)

Type Applies?
🚨 Breaking change (fix or feature that would cause existing functionality to change)
New feature (non-breaking change that adds functionality)
🐛 Bug fix (non-breaking change that fixes an issue)
🎨 User interface change (change to user interface; provide screenshots)
♻️ Refactoring (internal change to codebase, without changing functionality) X
🚦 Test update (change that only adds or modifies tests)
📦 Dependency update (change that updates a dependency)
🔧 Internal (change that only affects developers or continuous integration)

Checklist

(Complete each of the following items for your pull request. Indicate that you have completed an item by changing the [ ] into a [x] in the raw text, or by clicking on the checkbox in the rendered description on GitHub.)

Before opening your pull request:

  • I have performed a self-review of my changes.
    • Check that all changed files included in this pull request are intentional changes.
    • Check that all changes are relevant to the purpose of this pull request, as described above.
  • I have added tests for my changes, if applicable.
    • This is required for all bug fixes and new features.
  • I have updated the project documentation, if applicable.
    • This is required for new features.
  • If this is my first contribution, I have added myself to the list of contributors.
  • I have updated the project Changelog (this is required for all changes).

After opening your pull request:

  • I have verified that the CircleCI checks have passed.
  • I have requested a review from a project maintainer.

Questions and Comments

@coveralls

coveralls commented Jun 14, 2026

Copy link
Copy Markdown

Coverage Report for CI Build 4030048

Coverage decreased (-0.004%) to 58.608%

Details

  • Coverage decreased (-0.004%) from the base build.
  • Patch coverage: 16 uncovered changes across 4 files (22 of 38 lines covered, 57.89%).
  • 15 coverage regressions across 1 file.

Uncovered Changes

File Changed Covered %
app/WebParsing/ArtSciParser.hs 11 0 0.0%
app/Models/Course.hs 21 18 85.71%
app/Database/CourseVideoSeed.hs 1 0 0.0%
app/Database/Migrations.hs 3 2 66.67%
Total (5 files) 38 22 57.89%

Coverage Regressions

15 previously-covered lines in 1 file lost coverage.

File Lines Losing Coverage Coverage
app/Models/Course.hs 15 53.95%

Coverage Stats

Coverage Status
Relevant Lines: 3950
Covered Lines: 2377
Line Coverage: 60.18%
Relevant Branches: 964
Covered Branches: 503
Branch Coverage: 52.18%
Branches in Coverage %: Yes
Coverage Strength: 164.59 hits per line

💛 - Coveralls

Comment thread app/Database/Tables.hs

import Data.Aeson (FromJSON (parseJSON), ToJSON (toJSON), genericToJSON, withObject,
(.!=), (.:), (.:?))
import Data.Aeson (FromJSON (parseJSON), ToJSON (toJSON), genericToJSON, withObject, (.!=), (.:),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Revert this change

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I believe this change happened because of the husky pre-commit that occurred when I added my commit. I'm confident this is true because I attempted to make a new commit and push with just this change, but husky's pre-commit (specifically, the stylish-haskell step) told me that lint-staged failed and that it cannot make an empty commit.

I took a look at the stylish-haskell step, where long_list_align is set to inline (so the import tries to fit as many import items on one line as possible). I also noticed that it was previously crammed on one line within the codebase and this change (more imports go on the second line) was only introduced in PR #1720.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Ah that's interesting, okay you can leave this change as-is 👍

Comment thread app/WebParsing/ArtSciParser.hs Outdated
in
(Courses code
(Course code
(Just title)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Modify the rest of the indentation here to keep the arguments to Course aligned

Comment thread CHANGELOG.md Outdated
- Updated documentation in `app/Util/Blaze.hs`
- Moved the `Course` data type from `Database/Tables.hs` into `Models/Course.hs`, renamed it to `CourseData`
- Removed `SvgJSON` data type in favour of `([Text], [Shape], [Path])`
- Refactored the `Courses` table to `Course` with a database migration

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Do a merge from master and note the updated changelog (from the recent 0.8.0 release); make sure to put this entry under "unreleased")

Comment thread app/Export/GetImages.hs
import qualified Data.Text as T
import qualified Data.Text.Lazy.IO as LTIO
import Database.Tables as Tables
import Database.Tables (Time (..))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Revert this change

@AngelsandDevsLOL AngelsandDevsLOL Jun 14, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The reason I made this change was because the function addCourseHelper has a courseCode parameter, which overlapped with the courseCode accessor function from Database.Tables. It gave me a name-shadowing warning that didn't occur before because the accessor function was previously coursesCode. The husky pre-commit tests will pass, but the CircleCI tests won't pass.

I came up with 3 options:

  1. Rename the parameter to be cCode instead of courseCode so that it's different from the accessor function. However, I did notice that the other parameters were courseSession and courseSection, which is why I originally didn't change it. Alternatively, I could change all 3 parameters to be code, session, and section, or cCode, cSession, and cSection.
  2. Have import qualified Database.Tables as Tables by adding the qualified keyword, but that would involve more changes where several functions and datatypes would be relabelled with the prefix.
  3. Add a comment at the top of the file, ignoring the warning. I noticed this is already done in a few other files (ex: Database.Tables)

Should I continue with the 3rd option (adding a comment at the top of the file to ignore the warning?)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks @AngelsandDevsLOL, I didn't realize you changed this to avoid a name shadowing issue, but that does make sense. In that case you can leave the change the way you originally had it, including the (Time (..)). I agree that's the most elegant way to solve this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants