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

Treat block and timestamp buckets equally and separately #319

Merged
merged 5 commits into from
Oct 19, 2018

Conversation

kosecki123
Copy link
Contributor

Another (hopefully last) attempt to simplify and optimize bucket handling.

  • Treat all buckets the same and process separately so there are no unnecessary start/stops when one bucket in the pair has changed.

const nextBuckets = await this.getNextBuckets(latest);
const afterNextBuckets = await this.getAfterNextBuckets(latest);

return currentBuckets.concat(nextBuckets).concat(afterNextBuckets);
Copy link
Member

Choose a reason for hiding this comment

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

This line is completely okay, but worth to mention it would be also possible to do:

Suggested change
return currentBuckets.concat(nextBuckets).concat(afterNextBuckets);
return return [...currentBuckets, ...nextBuckets, ...afterNextBuckets];

Copy link
Contributor Author

Choose a reason for hiding this comment

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

New-school vs old-school 👍


public async stop() {
await Promise.all(this.buckets.map(b => b.stop()));
return;
Copy link
Member

Choose a reason for hiding this comment

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

No need for return here. It's implicit.

Suggested change
return;

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's needed, as I don't want to return Promise<void[]>

Copy link
Member

Choose a reason for hiding this comment

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

Why not have these functions return Promise<boolean> instead? This would probably need an extra reduce to check all values are true but it would better than returning void I think

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What should happen if some are not true ?

@coveralls
Copy link

coveralls commented Oct 19, 2018

Pull Request Test Coverage Report for Build 2182

  • 49 of 53 (92.45%) changed or added relevant lines in 7 files are covered.
  • 1 unchanged line in 1 file lost coverage.
  • Overall coverage decreased (-0.4%) to 76.504%

Changes Missing Coverage Covered Lines Changed/Added Lines %
src/Router/Router.ts 0 1 0.0%
src/Scanner/WatchableBucket.ts 12 15 80.0%
Files with Coverage Reduction New Missed Lines %
src/Util.ts 1 75.21%
Totals Coverage Status
Change from base Build 2174: -0.4%
Covered Lines: 924
Relevant Lines: 1149

💛 - Coveralls

@kosecki123 kosecki123 merged commit 4f6a511 into master Oct 19, 2018
@kosecki123 kosecki123 deleted the fix/bucket-logic-aftermath branch October 19, 2018 12:22
@kosecki123 kosecki123 restored the fix/bucket-logic-aftermath branch May 30, 2019 10:46
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.

None yet

4 participants