fix: deterministic pagination order for derived conclusions
created_at is the transaction timestamp, so conclusions derived in the same batch share it; add an id tie-breaker (mirroring the created_at direction) so /derived pagination can't skip or duplicate rows across page boundaries. Matches the existing precedent in query_documents_most_derived. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
parent
5f1752bd48
commit
a0563f261e
|
|
@ -1394,9 +1394,13 @@ def get_child_observations(
|
|||
if observed:
|
||||
stmt = stmt.where(models.Document.observed == observed)
|
||||
|
||||
# created_at is the transaction timestamp, so documents created in the
|
||||
# same batch share it -- id keeps pagination deterministic.
|
||||
if reverse:
|
||||
stmt = stmt.order_by(models.Document.created_at.asc())
|
||||
stmt = stmt.order_by(models.Document.created_at.asc(), models.Document.id.asc())
|
||||
else:
|
||||
stmt = stmt.order_by(models.Document.created_at.desc())
|
||||
stmt = stmt.order_by(
|
||||
models.Document.created_at.desc(), models.Document.id.desc()
|
||||
)
|
||||
|
||||
return stmt
|
||||
|
|
|
|||
Loading…
Reference in New Issue