Skip to content

Refactored parseReqs into a new module Models.Requirement - #1808

Merged
david-yz-liu merged 7 commits into
Courseography:masterfrom
danielrafailov:refactor-parse-reqs
Sep 27, 2026
Merged

david-yz-liu merged 7 commits into
Courseography:masterfrom
danielrafailov:refactor-parse-reqs

Conversation

@danielrafailov

@danielrafailov danielrafailov commented Sep 26, 2026 •

Copy link
Copy Markdown
Contributor

Proposed Changes

Refactored parseReqs into a new module Models.Requirement and updated its input type from String to Text.

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 CI checks have passed.
  • I have reviewed the test coverage changes reported by Coveralls.
  • I have requested a review from a project maintainer.

Questions and Comments

(Include any questions or comments you have regarding your changes.)

@danielrafailov danielrafailov changed the title refactored parseReqs into a new module Models.Requirement Refactored parseReqs into a new module Models.Requirement Sep 26, 2026
@coveralls

coveralls commented Sep 26, 2026 •

Copy link
Copy Markdown

Coverage Report for CI Build 36342591068

Warning

Build has drifted: This PR's base is out of sync with its target branch, so coverage data may include unrelated changes.
Quick fix: rebase this PR. Learn more →

Coverage increased (+0.7%) to 60.473%

Details

  • Coverage increased (+0.7%) from the base build.
  • Patch coverage: 2 uncovered changes across 2 files (9 of 11 lines covered, 81.82%).
  • 7 coverage regressions across 2 files.

Uncovered Changes

File Changed Covered %
app/Models/Requirement.hs 9 8 88.89%
app/WebParsing/ArtSciParser.hs 1 0 0.0%
Total (3 files) 11 9 81.82%

Coverage Regressions

7 previously-covered lines in 2 files lost coverage.

File Lines Losing Coverage Coverage
app/MasterTemplate.hs 4 0.0%
app/Scripts.hs 3 0.0%

Coverage Stats

Coverage Status
Relevant Lines: 4322
Covered Lines: 2673
Line Coverage: 61.85%
Relevant Branches: 1001
Covered Branches: 546
Branch Coverage: 54.55%
Branches in Coverage %: Yes
Coverage Strength: 156.54 hits per line

💛 - Coveralls

Comment thread app/Models/Requirement.hs Outdated
-- | Parses prerequisite strings into the Requirement datatype
parseReqs :: T.Text -> Req
parseReqs reqText =
let reqString = T.unpack reqText

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.

You can call T.toLower on the input text to avoid using the Data.Char.toLower later on

Comment thread app/Models/Requirement.hs Outdated

import Data.Char
import qualified Data.Text as T
import Database.Requirement

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.

In general, we're moving towards always including explicit or qualified imports. For this module and WebParsing.ReqParser below, include the specific names being imported for this module.

("for (" ++ y ++ "),")
z
(parseReqs y)
(parseReqs (T.pack y))

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.

All of the test inputs are string literals, so instead of using T.pack here you should be able to just change the data type from String to T.Text throughout. We're using the FlexibleStrings compiler extension, which should automatically convert string literals to the T.Text type.

import Database.Requirement
import Models.Requirement (parseReqs)

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.

With this PR's change, let's also move this entire test module file to backend-test/Models/RequirementModelTests.hs, renaming it as necessary. This will help keep the test file organization aligned with the application code organization.

@david-yz-liu david-yz-liu left a comment

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.

Nice work, @danielrafailov!

@david-yz-liu
david-yz-liu merged commit 34b7bb8 into Courseography:master Sep 27, 2026
3 checks passed
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