OP-2951 - change sort by depth

Previous sorting by _id might not be deterministic, not reliable. The main logic is to have outputs sorted by how they were traversed, which should be denoted by 'depth' field.
This commit is contained in:
Petr Kalis 2022-03-31 12:14:17 +02:00
parent af079897a8
commit b826cfac41

View file

@ -2067,7 +2067,7 @@ def _process_referenced_pipeline_result(result, link_type):
# outputs_recursive in random order, sort by _id
outputs_recursive = sorted(item.get("outputs_recursive", []),
key=lambda d: d["_id"])
key=lambda d: d["depth"])
# go from oldest to newest
# only older _id can reference another newer _id
for output in outputs_recursive[::-1]: