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

Convenience Method and naming clarification for as_of #1361

Open
ailandini-accenture opened this issue Jun 26, 2024 · 0 comments
Open

Convenience Method and naming clarification for as_of #1361

ailandini-accenture opened this issue Jun 26, 2024 · 0 comments

Comments

@ailandini-accenture
Copy link

Problem Statement
The convenience method as_of, which returns a historical queryset of object instances, is a bit confusing even when reading the documentation. Also, because it returns the object instances, if I ask for the as_of at a point in time where the instance no longer exists, I am unable to use to_historic to get the historical record used to retrieve that instance.

Describe the solution you'd like
I propose renaming as_of to instance_as_of and adding a second convenience method history_as_of whose implementation is (to borrow the documentation example) RankedDocument.history.filter(history_date__lte=t1).latest_of_each() to provide the historical records themselves more readily.

Describe alternatives you've considered
There's nothing wrong with using the latest_of_each method directly, and a specific call out to that in the documentation would provide easy clarity, but I have a feeling I may not be the only one who wrestled with as_of, forgetting that despite the return value of HistoricalQueryset, the members of that queryset are instances not histories.

Additional context
Let me know if what I'm asking isn't clear. And if you like the idea, but don't have the bandwidth, I'd be happy to whip a pr up for it on y'all's behalf.

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