-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor Downloader & testing #245
Conversation
8f84090
to
b524fed
Compare
b524fed
to
a9704c9
Compare
.through(fs2.text.lines) | ||
.drop(1) // first line is header | ||
.evalMap(parseLine) | ||
.collect { case Some(x) => x } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you have such sharp eyes, thanks!
.map(x => x._2) | ||
.fold[Set[FederationId]](Set.empty)((acc, x) => acc ++ x.map(_.id)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this
.mapFilter(x => x._2.map(_.id))
.compile
.to(Set)
less preferable?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change also eliminates .last
part, I guess
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
couldn't use mapFilter
, probably IO
is not a FunctorFilter
, so this is the best I came up with: 3010f83. thanks again, really love your reviews!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, looks great 👍🏻 (I haven't been sure if .to(Set)
works). But I suppose mapFilter
works here, because there is no bound for F[_]
for Stream[F[_], A].mapFilter
, scastie for reference
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh, it was me, I forgot to import cats.syntax.all.*
🤦
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.evalMap(parseLine) | ||
.collect { case Some(x) => x } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can shorten it to just .evalMapFilter(parseLine)
(source)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Split database update from Downloader, which makes the concern clearer
which in turns makes testing easier.