Move QueryCondition/QueryOrder query primitives down from repositories.base to the models layer
- Dominant language
- Python
- Stars
- 670
- Forks
- 183
- Avg merge
- 15h 13m
- Merged PRs (30d)
- 368
Description
Category E (largest): 84 files under models/**/conditions.py and models/**/orders.py import QueryCondition / QueryOrder (and BatchPurger / execute_batch_purger) from repositories.base – models (DB layer) importing repositories (upper layer).
These are plain SQLAlchemy type aliases (QueryCondition = Callable[[], ColumnElement[bool]]; QueryOrder = UnaryExpression | ColumnElement), not repository logic – they belong at or below the models layer.
Fix: move the type aliases to a neutral lower location (e.g. models/base/types.py); have repositories.base re-export from there. Relocate BatchPurger/execute_batch_purger usage in models/vfolder/row.py.
Success criteria:
- QueryCondition/QueryOrder defined at/below models layer; no models/\* file imports from repositories.\*
- repositories continue to resolve the same symbols (re-export or direct import from new location)
- pants check / lint / test pass for affected packages
JIRA Issue: BA-6608
Contributor guide
Research direction
Start by reviewing the imports in models/**/conditions.py and models/**/orders.py, then inspect repositories/base and models/vfolder/row.py. Trace the current QueryCondition, QueryOrder, BatchPurger, and execute_batch_purger references before choosing the lower location for the aliases. Done means the models files no longer import from repositories, repositories still resolve the symbols, and pants check, lint, and affected-package tests pass.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python, sqlalchemy
- Domain
- backend, database
- Issue type
- Refactor
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 52/100