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

Remove delta comparison for fillup #8

Merged
merged 3 commits into from
Dec 16, 2023
Merged

Remove delta comparison for fillup #8

merged 3 commits into from
Dec 16, 2023

Conversation

julik
Copy link
Contributor

@julik julik commented Nov 28, 2023

It is better to let the DB compare the level to the capacity (using it's own float representation) and to return based on that. Since we use LEAST the value would be equal (exactly) to capacity at overflow.

Closes #7

It is better to let the DB compare the level to the
capacity (using it's own float representation) and to
return based on that. Since we use LEAST the value would be
equal (exactly) to capacity at overflow.

Closes #7
@julik julik requested a review from skatkov November 28, 2023 11:45
@skatkov
Copy link
Contributor

skatkov commented Nov 30, 2023

Since we have a changelog, it would be great if we can document this change there as well.

# correctly, thus the clock_timestamp() value would be frozen between calls. We don't want that here.
# See https://stackoverflow.com/questions/73184531/why-would-postgres-clock-timestamp-freeze-inside-a-rails-unit-test
level_after_fillup = conn.uncached { conn.select_value(sql) }
upserted = conn.uncached { conn.select_one(sql) }
capped_level_after_fillup, did_fillup = upserted.fetch("level"), upserted.fetch("did_fillup")
Copy link
Contributor

Choose a reason for hiding this comment

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

Variable naming makes me a bit cringe here.

Can I suggest did_fillup => is_filled or is_full and capped_level_after_fillup => adjusted_level?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The naming is very deliberate, did_fillup is a better tense than is_filled (it denotes a definite transition of state, i.e. "something did take place"). We can alternatively use did_overflow if you would prefer that. adjusted_level is not a good name because it assumes there is "some kind of adjustment", whereas "capped" (or "clamped") tells the reader what kind of adjustment has been done.

@julik julik merged commit 67d3dda into main Dec 16, 2023
2 checks passed
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.

Bucket filling up is still an approximation
2 participants