Repository navigation
refactor(report): split the row-scope predicate builder into steps - #1494
Merged
Merged
Conversation
Refactor lane. Pins the exact SQL text and bound values that append_row_scope (db/report_read/scope.rs) emits across 17 cases: every RowScope, a source with and without the closedate column, one and two offset groups, bounded, one-sided and ended windows, an unscoped read with its catch-all group, a core whose offset changed inside the period, and the open-date basis. Taken from the untouched code, so the next commit can split the function into its steps and prove its output unchanged. Re-run: cargo test -p moon-core --lib report_read::scope::tests
Refactor lane. Signal: oversized function. append_row_scope (crates/moon-core/src/db/report_read/scope.rs:149) ran 202 lines, over the 120-line limit. It now reads as its steps (42 lines) and hands each one to a private helper in the same file: - shifted_window (scope.rs:216): one offset group's shifted period window, its bound values and shifted bounds - group_predicates (scope.rs:257): resolves every offset group into its predicate part; None keeps the old "emit nothing" exit for a source without the closedate column - append_open_if_current (scope.rs:340): the hoisted OpenIfCurrent open test with the current groups' guards - append_coarse_range (scope.rs:378): closed branches under the shared coarse closedate range - append_group_branches (scope.rs:424): one self-contained branch per group - GroupPredicate::close_over (scope.rs:588): the closed side and its window, previously spelled twice The SQL text, the bound values and their order, the single clock read and every early exit are unchanged; no public item changes. Lines: append_row_scope 202 -> 42; largest helper 71. Tests: scope/tests.rs (previous commit) pins the exact SQL and bound values over 17 cases covering every branch, green before and after; the report-read suites in db/report_read/tests.rs and tests/*.rs also run it. Re-run: cargo test -p moon-core --lib report_read::scope::tests cargo test -p moon-core --lib db:: (1580 passed) Reviewer: Codex. Its one finding was the drop order of owned temporaries (String, Vec<Box<i64>>), which have no custom Drop and are not observable by any caller.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
refactor(report): split the row-scope predicate builder into steps
Refactor lane. Signal: oversized function. append_row_scope
(crates/moon-core/src/db/report_read/scope.rs:149) ran 202 lines,
over the 120-line limit. It now reads as its steps (42 lines) and
hands each one to a private helper in the same file:
window, its bound values and shifted bounds
its predicate part; None keeps the old "emit nothing" exit for a
source without the closedate column
open test with the current groups' guards
shared coarse closedate range
per group
window, previously spelled twice
The SQL text, the bound values and their order, the single clock
read and every early exit are unchanged; no public item changes.
Lines: append_row_scope 202 -> 42; largest helper 71.
Tests: scope/tests.rs (previous commit) pins the exact SQL and bound
values over 17 cases covering every branch, green before and after;
the report-read suites in db/report_read/tests.rs and tests/*.rs
also run it. Re-run:
cargo test -p moon-core --lib report_read::scope::tests
cargo test -p moon-core --lib db:: (1580 passed)
Reviewer: Codex. Its one finding was the drop order of owned
temporaries (String, Vec<Box>), which have no custom Drop and
are not observable by any caller.