refactor(farm_base): extract farm.rank.mixin from observation + fence#10
Open
dnplkndll wants to merge 1 commit into
Open
refactor(farm_base): extract farm.rank.mixin from observation + fence#10dnplkndll wants to merge 1 commit into
dnplkndll wants to merge 1 commit into
Conversation
Both farm_observation.urgency_rank and farm_fence.condition_rank implement the same pattern: a Selection field whose alphabetical order doesn't match priority order, paired with a stored computed Integer that mirrors it so `_order` produces a real priority sort. Extract the shared mechanism into farm.rank.mixin (in farm_base): subclasses set _rank_selection_field + _rank_value_map class attrs and use `_order = "rank desc, ..."` to pick up the rank column the mixin contributes. Migration concern: renaming `urgency_rank` → `rank` and `condition_rank` → `rank` is a schema change. farm-pack just shipped these models at 19.0.1.0.0 and no production installs exist yet, so no migration script is needed — bump to 19.0.1.1.0 and accept the column rename. Version bumps: farm_base, farm_observation, farm_fence → 19.0.1.1.0.
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.
What changed
Both
farm_observation.urgency_rankandfarm_fence.condition_rankimplemented the same pattern: a Selection field whose alphabetical order doesn't match priority order, paired with a stored-computed Integer mirror used as the sort key in_order.This PR extracts that mechanism into
farm.rank.mixin(infarm_base). Subclasses now declare just:…and pick up the stored, indexed
rankinteger the mixin contributes. The two consumers each drop ~10 lines.Migration
Renaming
urgency_rank→rankandcondition_rank→rankis a column rename. farm-pack just shipped these models at 19.0.1.0.0 and no production installs exist yet, so this PR bumps to 19.0.1.1.0 and accepts the rename without a migration script.Tests
farm_base/tests/test_rank_mixin.py— new — confirms the abstract model registers and therankfield declaresstore=True, index=True, readonly=True.farm_observation+farm_fence(test_urgency_sort_priority_not_alphabetical,test_condition_sort_priority_not_alphabetical) keep passing — they assert search-result order, which doesn't care which field holds the rank.Test plan
19.0farm_observation+farm_fence, confirm therankcolumn is created and grouped kanbans put high-urgency / repair items on top