Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some model methods should have corresponding redundant fields to store generated values for quick filtering and sorting #3

Open
shatsky opened this issue Oct 6, 2013 · 1 comment

Comments

@shatsky
Copy link
Owner

shatsky commented Oct 6, 2013

Examples:
we need recording listen count numbers to show top listened recordings;
we need numbers of pieces and recordings associated with people to sort people on catalog pages by these numbers;
we need derived person name forms to do quick lookups for person objects matching string names when importing music from webpages (currently implemented in ExtPersonName table).

It would be nice to implement these as a method decorator, something like:
@stored
def method(): ...

@shatsky
Copy link
Owner Author

shatsky commented Oct 21, 2013

In-database count ordering can be performed without extra fields with annotate() django ORM method.
There is now a title field in models.Recording. Its values can get out of sync if pieces are modified, but we can perform an ordering check following the title inheriting logic in Python code after the query (just the check, which is much faster than pythonic sort), then proceed if everything is OK (usually it should be) or perform a pythonic sort and initiate a background title sync if the order is broken.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant