Skip to content
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

Merged
merged 4 commits into from
Jan 31, 2025
Merged

Refactor Downloader & testing #245

merged 4 commits into from
Jan 31, 2025

Conversation

lenguyenthanh
Copy link
Owner

@lenguyenthanh lenguyenthanh commented Jan 31, 2025

Split database update from Downloader, which makes the concern clearer
which in turns makes testing easier.

@lenguyenthanh lenguyenthanh merged commit 7691e26 into main Jan 31, 2025
3 checks passed
@lenguyenthanh lenguyenthanh deleted the parser-testing branch January 31, 2025 18:06
.through(fs2.text.lines)
.drop(1) // first line is header
.evalMap(parseLine)
.collect { case Some(x) => x }
Copy link
Collaborator

@Masynchin Masynchin Jan 31, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Owner Author

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!

Comment on lines +22 to +23
.map(x => x._2)
.fold[Set[FederationId]](Set.empty)((acc, x) => acc ++ x.map(_.id))
Copy link
Collaborator

@Masynchin Masynchin Jan 31, 2025

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?

Copy link
Collaborator

@Masynchin Masynchin Feb 1, 2025

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

Copy link
Owner Author

@lenguyenthanh lenguyenthanh Feb 1, 2025

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!

Copy link
Collaborator

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

Copy link
Owner Author

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.* 🤦

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment on lines +35 to +36
.evalMap(parseLine)
.collect { case Some(x) => x }
Copy link
Collaborator

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)

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

2 participants