[backend] Use a stack instead of queue when backfilling
This makes each reply chain load completely before loading the next chain, instead of the current behavior that loads all replies of one depth before loading the next "layer". This won't make much of a difference *now*, but should result in more intuitive behavior when live updating of newly loaded replies gets implemented.
This commit is contained in:
parent
40b35a7bd2
commit
94328a3eef
1 changed files with 14 additions and 14 deletions
|
@ -62,8 +62,8 @@ public class BackfillQueue(int parallelism)
|
|||
.Select(n => new BackfillData(n.Id, n.RepliesCollection!))
|
||||
.ToArrayAsync(token);
|
||||
|
||||
var toBackfill = new Queue<BackfillData>(toBackfillArray);
|
||||
while (toBackfill.TryDequeue(out var currentItem))
|
||||
var toBackfill = new Stack<BackfillData>(toBackfillArray);
|
||||
while (toBackfill.TryPop(out var currentItem))
|
||||
{
|
||||
var current = currentItem;
|
||||
if (!history.Add(current.RepliesCollection))
|
||||
|
@ -108,7 +108,7 @@ public class BackfillQueue(int parallelism)
|
|||
(note.RepliesFetchedAt == null ||
|
||||
note.RepliesFetchedAt <= DateTime.UtcNow - cfg.RefreshAfterTimeSpan))
|
||||
{
|
||||
toBackfill.Enqueue(new BackfillData(note.Id, note.RepliesCollection!));
|
||||
toBackfill.Push(new BackfillData(note.Id, note.RepliesCollection!));
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
|
|
Loading…
Add table
Reference in a new issue