-
Notifications
You must be signed in to change notification settings - Fork 30
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
Reduce GitHub API calls in issues reporter #1113
Conversation
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.
Thanks for this work!
The caching mechanism is a bit too eager from my perspective: I believe we would make it significantly simpler by simply having a getter that populates when it is requested for the first time, and better encapsulating its updates 🙂
src/reporter/github.js
Outdated
} | ||
} | ||
|
||
async ensureCacheLoaded() { |
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.
Why not simply await this.cacheLoadedPromise
when we call ensureCacheLoaded()
? 🙂 Then we don't need to await
it in refreshIssuesCache()
and we don't need this method.
src/reporter/github.js
Outdated
|
||
return issue; | ||
getIssue(title) { | ||
return this.issuesCache.get(title) || null; |
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.
Why isn't undefined
acceptable as a return value if the issue is not found in the cache? 🙂
return this.issuesCache.get(title) || null; | |
return this.issuesCache.get(title); |
src/reporter/index.js
Outdated
@@ -49,6 +49,10 @@ export default class Reporter { | |||
return this.github.initialize(); | |||
} | |||
|
|||
onTrackingStarted() { | |||
return this.github.refreshIssuesCache(); |
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.
Why be eager? Let's just wait until we actually need the cache 🙂
Co-authored-by: Matti Schneider <matti@opentermsarchive.org>
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.
Looks really good, thanks!!
No description provided.