-
Notifications
You must be signed in to change notification settings - Fork 3
Consolidate models and tests into single files, extract database utilities #389
Conversation
Co-authored-by: danjac <249779+danjac@users.noreply.github.com>
Co-authored-by: danjac <249779+danjac@users.noreply.github.com>
danjac
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Move fields.py and search.py into a new package, simplecasts/db.
- Remove the all at the bottom of the page.
| @@ -1,19 +1,72 @@ | |||
| import datetime | |||
| from datetime import timedelta | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rename this file test_models.py
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in commit 393b89d. Renamed to test_models.py
Co-authored-by: danjac <249779+danjac@users.noreply.github.com>
danjac
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rename models/init.py to models.py. Remove models package.
Done in commit c8be4f0. Created
|
danjac
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move validators.py to db/validators.py
…rs to db Co-authored-by: danjac <249779+danjac@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some food for thought. View full project report here.
| ) | ||
|
|
||
|
|
||
| class Podcast(models.Model): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This model has lots of fields. Consider splitting into multiple models. Explained here.
Refactored Django models and tests from multiple individual files into consolidated single files for improved maintainability and discoverability. Database utilities extracted into a dedicated package.
Changes
Models consolidation
simplecasts/models.py(808 lines)users.py,categories.py,podcasts.py,episodes.py,subscriptions.py,bookmarks.py,audio_logs.py,recommendations.pySeasondataclassmodels/__init__.py) to single file (models.py)Tests consolidation
simplecasts/tests/test_models.py(563 lines)models.pytotest_models.pyto follow pytest conventionsDatabase utilities package (new)
simplecasts/db/package for reusable database utilitiesdb/fields.py- ContainsURLFieldwith sensible defaultsdb/search.py- ContainsSearchQuerySetMixinfor full-text searchdb/validators.py- Containsurl_validator(moved from root)__all__from models module for cleaner exportsImport updates
admin.pyto import QuerySets from consolidated models modulesimplecasts.dbsimplecasts.db.validatorslocationfrom simplecasts.models import ...statements remain compatibleImport compatibility
Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.