You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
The text was updated successfully, but these errors were encountered:
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 theas_of
at a point in time where the instance no longer exists, I am unable to useto_historic
to get the historical record used to retrieve that instance.Describe the solution you'd like
I propose renaming
as_of
toinstance_as_of
and adding a second convenience methodhistory_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 withas_of
, forgetting that despite the return value ofHistoricalQueryset
, 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.
The text was updated successfully, but these errors were encountered: