• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

Courseography / courseography / 6ca2fc21-e28e-4b1f-931e-25ce91baa664

16 Sep 2025 02:22AM UTC coverage: 54.687%. Remained the same
6ca2fc21-e28e-4b1f-931e-25ce91baa664

push

circleci

web-flow
Refactored Database files to MVC architecture (#1604)

* created Program file in models folder
* created Meeting file in models folder
* removed CourseQueries.hs and CourseInsertion.hs
* renamed post -> program across the codebase, excluding database tables and route names

485 of 952 branches covered (50.95%)

Branch coverage included in aggregate %.

31 of 87 new or added lines in 6 files covered. (35.63%)

2 existing lines in 1 file now uncovered.

2187 of 3934 relevant lines covered (55.59%)

160.4 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

68.75
/app/Models/Program.hs
1
module Models.Program
2
    (returnProgram,
3
    reqsForProgram) where
4

5
import Config (runDb)
6
import Data.Char (isAlpha, isAlphaNum, isDigit, isPunctuation)
7
import qualified Data.Text as T (Text, unpack)
8
import Database.Persist.Sqlite (entityVal, selectFirst, (==.))
9
import Database.Tables
10

11
-- | Queries the database for information about the program then returns the post value
12
returnProgram :: T.Text -> IO (Maybe Post)
NEW
13
returnProgram code = runDb $ do
×
NEW
14
    sqlProgram <- selectFirst [PostCode ==. code] []
×
NEW
15
    case sqlProgram of
×
NEW
16
        Nothing -> return Nothing
×
NEW
17
        Just program -> return $ Just $ entityVal program
×
18

19
-- | Retrieves the course requirements for a Post (program) as a list of course codes
20
reqsForProgram :: Post -> [String]
21
reqsForProgram program = do
3✔
22
    let requirementsText = T.unpack $ postRequirements program
3✔
23
        cleaned = filter (`notElem` ("<>" :: String)) $ filter (not . isPunctuation) requirementsText
3✔
24
        potentialCodes = words cleaned
3✔
25
    filter isCourseCode potentialCodes
3✔
26
  where
27
    -- | TODO: change function to use a regex
28
    isCourseCode :: String -> Bool
29
    isCourseCode codeStr =
30
        length codeStr == 8 &&
1✔
31
        all isAlphaNum codeStr &&
1✔
32
        all isAlpha (take 3 codeStr) &&
1✔
33
        all isDigit (take 3 (drop 3 codeStr)) &&
1✔
34
        isAlpha (codeStr !! 6) &&
1✔
35
        isDigit (codeStr !! 7)
1✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc