Split oversized database command functions into focused helpers#47
Merged
Split oversized database command functions into focused helpers#47
Conversation
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.
Summary
Split the largest functions in
database.tsinto smaller, focused helpers to improve readability and reduce duplication. Pure refactor — no behavior changes.Changes
viewUpdateActiondecompositionapplyVisibilityUpdates()--showand--hideoptions into property visibility flags.applyReorderUpdates()--reorderoption.applyResizeUpdates()--resizeoption.parseCommaSeparatedNames()viewUpdateActionis now an orchestrator that delegates to these three helpers instead of inlining all the logic in one 167-line body.serializeRowPropertiesdecompositionserializePropertyValue()serializeTitleProperty()serializeSelectProperty()serializeMultiSelectProperty()serializeNumberProperty()serializeCheckboxProperty()serializeDateProperty()‣marker format.serializeTextProperty()serializePersonProperty()‣+uannotation segments.serializeRelationProperty()‣+pannotation segments.serializeDefaultProperty()The original 85-line if/else chain becomes a 4-line loop body calling
serializePropertyValue().Shared helpers for add-row and update-row
buildSchemaNameToId()createSchemaOptionRegistrar()buildSerializedInputProperties()buildRowPropertySetOperations()setoperation array forsaveTransactions.unknownPropertyError()resolvePropertyIdOrThrow()handleDatabaseAddRowandhandleDatabaseUpdateRowpreviously duplicated the schema-to-nameToId loop and the option registration closure verbatim. Both now call the shared helpers.Context
database.tshad several functions that exceeded comfortable readability thresholds.viewUpdateActionat 167 lines mixed three independent concerns (visibility, reorder, resize) in one body.serializeRowPropertiesat 85 lines was a long if/else chain where each branch was self-contained. The add-row and update-row handlers duplicated ~20 lines of identical schema setup code. Extracting focused helpers makes each unit independently understandable and eliminates the duplication.Testing
Pure refactor — no behavioral changes. All existing tests pass unchanged:
bun run typecheckclean,bun test src/= 599 pass / 0 fail, database tests = 50 pass / 0 fail.Summary by cubic
Split oversized database command functions into small, focused helpers to improve readability and remove duplication. Pure refactor with no behavior changes; tests pass unchanged.
applyVisibilityUpdates,applyReorderUpdates,applyResizeUpdates, andparseCommaSeparatedNames.serializePropertyValueand type-specific serializers (title, select/status, multi-select, number, checkbox, date, text/url/email/phone, person, relation, default).buildSchemaNameToId,createSchemaOptionRegistrar,buildSerializedInputProperties,buildRowPropertySetOperations,resolvePropertyIdOrThrow, andunknownPropertyError.Written for commit f45095b. Summary will update on new commits.