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

Fixing issue #19 #30

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open

Fixing issue #19 #30

wants to merge 6 commits into from

Conversation

m1ome
Copy link
Contributor

@m1ome m1ome commented Jul 18, 2023

No description provided.

list
end

def from_steam(list, opts \\ []) do
Copy link
Owner

Choose a reason for hiding this comment

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

steam -> stream :)

Copy link
Owner

@henrik henrik left a comment

Choose a reason for hiding this comment

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

Hi! Thanks so much – wrote some comments.

Would you be OK also updating the README to document the new functionality? I might do another round on that after but it would be great to have as a starting point.


import ExUnit.CaptureIO

test "it should work with enums" do
Copy link
Owner

Choose a reason for hiding this comment

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

Could you please write these without "should" to match other tests, e.g. "it works …"?

import ExUnit.CaptureIO

test "it should work with enums" do
capture_io(fn ->
Copy link
Owner

Choose a reason for hiding this comment

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

Could you make the tests cover more of actual behaviour? I feel like they should cover:

  • That it outputs a progress bar (ideally that it does so bit by bit as it iterates, but at least checking for the final state after the iteration).
  • That it calls the callback function once per iteration.
  • What the function returns (we do on line 19 below but not here).

end

def from_steam(list, opts \\ []) do
total = Enum.count(list)
Copy link
Owner

Choose a reason for hiding this comment

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

My Elixir is rusty (haven't written much in the past few years) and I never were super familiar with streams.

Is it reasonable to execute the stream here by counting the length? It was suggested in #19 that the length could be passed in, but I'm not sure in what situations you might know the length and also have a stream that you don't want to execute here. The user will need to execute it again after the map/each below to get any output.

cc @kelvinst if you remember or still have any specific use case around this where this detail would matter.

Copy link
Contributor

Choose a reason for hiding this comment

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

Well thought. I can't think of a case where one would have the length of a stream before actually going through it. Maybe one would already go through the stream of another operation and already have its length, but then it does not make sense to attach a progress bar after that again, IDK.

Anyway, I think it's ok to get the length this way, we might just want to warn people that the Stream is going to be traversed to get its final length and print the %

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I will add this message to readme

lib/progress_bar.ex Show resolved Hide resolved
@m1ome
Copy link
Contributor Author

m1ome commented Aug 3, 2023

@henrik thank you for you review, i added changes you requested for!

@m1ome m1ome requested review from henrik and kelvinst August 10, 2023 08:16
Copy link
Contributor

@kelvinst kelvinst left a comment

Choose a reason for hiding this comment

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

LGTM!

@m1ome
Copy link
Contributor Author

m1ome commented Aug 21, 2023

@henrik kind reminder

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