This repository was archived by the owner on Oct 25, 2023. It is now read-only.
Sort nodes by "crated-at" time in node iterator, latest first #430
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Resolves: #431
Root task : #351
Problem
Fragments in truthsayer feed are always ordered by creation date, for that node iterator should return them already ordered.
If nodes are created always "late after early", the existing code works. But, when browser history bootstrap engaged OR sync from date centre to local storage engaged, nodes are added at arbitrary order. Thus nodes in search grid are ordered incorrectly.
Solution
For that I had to change the structure of
all-nids
"lav" a little, using structure there that includesnid
and additional fields, that are used to re-order nodes by. Right now, there is only one "sort by" field -created_at
, a time stamp of node creation. Every time, when "all-nids" are requested, returned nids are sorted bycreated_at
time.Alternative solution
...that I've considered and decided not to implement: creation a separate index
yek - lav
for creation date. This way, all-nids are not ordered but at the creation of iterator, we'd fetch creation date for each nide using indexnid-> created_at
. Thus there will beN + 1
async calls for each creation of iterator, which is quite slow, I'm afraid.