Skip to content

Commit

Permalink
Filter out rating that lower than 1400
Browse files Browse the repository at this point in the history
fix #253
  • Loading branch information
lenguyenthanh committed Feb 1, 2025
1 parent 9f0962c commit fb3f3db
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
13 changes: 12 additions & 1 deletion modules/crawler/src/test/scala/ParserTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,18 @@ object ParserTest extends SimpleIOSuite:
)
lines
.traverse(parse)
.map(_.flatten.map(_.active))
.map(_.flatMap(_.map(_.active)))
.map(x => expect(x == List(false, false, true, true)))

test("rating constraints"):
val lines = List(
"10001492 Ojok, Patrick UGA M FI,LSI 900 0 20 1932 0 20 1926 0 20 1974 ",
"10001492 Ojok, Patrick UGA M FI,LSI 4002 0 20 1932 0 20 1926 0 20 1974 ",
"10001492 Ojok, Patrick UGA M FI,LSI 2700 0 20 1932 0 20 1926 0 20 1974 "
)
lines
.traverse(parse)
.map(_.flatMap(_.flatMap(_.standard)))
.map(x => expect(x == List(2700)))

private def parse(s: String) = Downloader.parse(s).map(_.map(_._1))
2 changes: 1 addition & 1 deletion modules/types/src/main/scala/Rating.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import cats.syntax.all.*
import io.github.iltotore.iron.*
import io.github.iltotore.iron.constraint.all.*

type RatingConstraint = GreaterEqual[0] & LessEqual[4000]
type RatingConstraint = GreaterEqual[1400] & LessEqual[4000]
opaque type Rating <: Int = Int :| RatingConstraint

object Rating extends RefinedTypeOps[Int, RatingConstraint, Rating]:
Expand Down

0 comments on commit fb3f3db

Please sign in to comment.