Skip to content

Refactor createReqBody - #1818

Merged
david-yz-liu merged 8 commits into
Courseography:masterfrom
PeanutPiglet:refactor-createReqBody
Oct 18, 2026
Merged

david-yz-liu merged 8 commits into
Courseography:masterfrom
PeanutPiglet:refactor-createReqBody

Conversation

@PeanutPiglet

@PeanutPiglet PeanutPiglet commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

Proposed Changes

Refactored the createReqBody under app/Config.hs to use settings from config.yaml

Type of Change

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

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.)

@coveralls

coveralls commented Oct 15, 2026 •

Copy link
Copy Markdown

Coverage Report for CI Build 39146595171

Coverage decreased (-0.03%) to 60.381%

Details

  • Coverage decreased (-0.03%) from the base build.
  • Patch coverage: 5 uncovered changes across 2 files (1 of 6 lines covered, 16.67%).
  • No coverage regressions found.

Uncovered Changes

File Changed Covered %
app/Config.hs 4 1 25.0%
app/WebParsing/UtsgJsonParser.hs 2 0 0.0%

Coverage Regressions

No coverage regressions found.


Coverage Stats

Coverage Status
Relevant Lines: 4307
Covered Lines: 2659
Line Coverage: 61.74%
Relevant Branches: 1001
Covered Branches: 546
Branch Coverage: 54.55%
Branches in Coverage %: Yes
Coverage Strength: 156.82 hits per line

💛 - Coveralls

@PeanutPiglet

Copy link
Copy Markdown
Contributor Author

Hello David, I noticed the Coveralls report says the coverage has decreased. I checked with previous reports locally, and it seems like the lines were uncovered before. Would you like me to add the tests to cover these lines?

Comment thread config.yaml
Comment thread config.yaml Outdated
fasCalendarUrl: "https://artsci.calendar.utoronto.ca/"
programsUrl: "https://artsci.calendar.utoronto.ca/listing-program-subject-areas"

# Data Fetching Parameters

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.

use lowercase for "fetching parameters"

Comment thread app/Config.hs Outdated
]
createReqBody :: Int -> IO Value
createReqBody page = do
sessions <- timetableSessionsValue <$> loadConfig

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 response to your comment in our meeting: you can load the configuration in makeRequest and then pass in the sessions as a plain [T.Text] argument here, so the function remains pure: [T.Text] -> Int -> Value.

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.

Hello David, I have adjusted the pipeline to export the session value from Config.hs instead of having makeRequest do another config reading. However, I am not sure if this is what you wanted. Would it be better to actually just keep the createReqBody impure or actually read the config in makeRequest?

@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 @PeanutPiglet, yes this approach for keeping createReqBody pure is good 👍

@david-yz-liu
david-yz-liu merged commit 8bcaf89 into Courseography:master Oct 18, 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