-
Notifications
You must be signed in to change notification settings - Fork 27
Conversation
@page_size = page_size | ||
end | ||
|
||
def loop_through_activities |
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.
traverse
is the word cool kids use
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.
flatmap
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.
@oreoshake wow, you're so cool
class Activities | ||
include ResourceHelper | ||
|
||
DOTFILE = '.hackerone_client_incremental_activities'.freeze |
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 your plan to store the latest fetched thing in this file? If so, that isn't going to work if you have more than one machine that uses this lib and I would let this up to the user how to store this data.
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.
Yup, that's the plan! We need some kind of persistent storage to store the updated_at_after
value, which essentially acts like a cursor.
I think you have a point, let's remove this logic?
def loop_through_activities | ||
load_dotfile | ||
|
||
loop do |
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.
Isn't while next_page
what you want?
Nice feature! If this works, we can remove a lot of request to our servers :D |
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.
I'll take another pass over this but it I'm having some trouble tracing through the code (maybe I haven't had enough ☕
end | ||
|
||
def current_page | ||
@current_page ||= make_get_request( |
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.
I think avoiding memoization here can clean up some of the state introduced by the ivars.
File.join(Dir.home, DOTFILE) | ||
end | ||
|
||
def next_updated_at_after |
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 method name is a little hard to grok.
@@ -0,0 +1,101 @@ | |||
module HackerOne |
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.
For this file in general, I think the tiny methods might work better as inline code with a comment rather than a separate one line method that's only called in one place. I think avoiding ivars in favor of locals will help readability. Double emphasis on think.
I tried cleaning it up a bit. Is this helpful? |
Looks like there's a merge conflict, otherwise 👍 |
It appears there's a bit of an issue with the endpoint, in that it may get stuck repeating the last page infinitely. I'm hoping I'll be able to fix this, and I'll finish off this PR at that point. |
Alright! I'm happy with the PR in it's current state. Curious to know what you think! |
This is a feature based on the discussion in #25. Essentially, it allows you to fetch all activities of your program incrementally. The idea here is this acts like a stream; you start at one point and keep moving forward in time until you run out of activities. As mentioned in #25, this feature has multiple usages:
The code is still a bit rough, but I envision it being used something like this:
Before I go on writing tests, I'd be curious to see what you think of this feature, and if you have any suggestions on how to improve it.