Fix unrelated flaky test

This commit is contained in:
Alejandro García Montoro
2026-04-13 11:56:02 +02:00
parent 4ab5ade80b
commit a289015637
2 changed files with 16 additions and 3 deletions
@@ -204,9 +204,16 @@ func (s SearchFileInfoStore) Search(rctx request.CTX, paramsList []*model.Search
if nErr != nil {
return nil, nErr
}
filesMap := make(map[string]*model.FileInfo, len(files))
for _, f := range files {
filesList.AddFileInfo(f)
filesList.AddOrder(f.Id)
filesMap[f.Id] = f
}
// Iterate over fileIds to preserve the search engine's ranking order.
for _, id := range fileIds {
if f, ok := filesMap[id]; ok {
filesList.AddFileInfo(f)
filesList.AddOrder(f.Id)
}
}
}
return filesList, nil
@@ -180,8 +180,14 @@ func (s SearchPostStore) searchPostsForUserByEngine(engine searchengine.SearchEn
if err != nil {
return nil, err
}
postsMap := make(map[string]*model.Post, len(posts))
for _, p := range posts {
if p.DeleteAt == 0 {
postsMap[p.Id] = p
}
// Iterate over postIds to preserve the search engine's ranking order.
for _, id := range postIds {
p, ok := postsMap[id]
if ok && p.DeleteAt == 0 {
postList.AddPost(p)
postList.AddOrder(p.Id)
}