4cddfcf2f3
Backend Tests / Tests (other) (push) Failing after 1s
Backend Tests / Static Checks (push) Failing after 2s
Backend Tests / Tests (internal) (push) Failing after 2s
Backend Tests / Tests (server) (push) Failing after 1s
Backend Tests / Tests (store) (push) Failing after 1s
Build Canary Image / build-frontend (push) Failing after 1s
Frontend Tests / Lint (push) Failing after 1s
Build Canary Image / build-push (linux/amd64) (push) Has been skipped
Build Canary Image / build-push (linux/arm64) (push) Has been skipped
Build Canary Image / merge (push) Has been skipped
Frontend Tests / Build (push) Failing after 1s
Release Please / release-please (push) Failing after 0s
Proto Linter / Lint Protos (push) Failing after 2s
35 lines
787 B
Go
35 lines
787 B
Go
package v1
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/usememos/memos/store"
|
|
)
|
|
|
|
func (s *APIV1Service) listMemosByID(ctx context.Context, memoIDs []int32) (map[int32]*store.Memo, error) {
|
|
if len(memoIDs) == 0 {
|
|
return map[int32]*store.Memo{}, nil
|
|
}
|
|
|
|
uniqueMemoIDs := make([]int32, 0, len(memoIDs))
|
|
seenMemoIDs := make(map[int32]struct{}, len(memoIDs))
|
|
for _, memoID := range memoIDs {
|
|
if _, seen := seenMemoIDs[memoID]; seen {
|
|
continue
|
|
}
|
|
seenMemoIDs[memoID] = struct{}{}
|
|
uniqueMemoIDs = append(uniqueMemoIDs, memoID)
|
|
}
|
|
|
|
memos, err := s.Store.ListMemos(ctx, &store.FindMemo{IDList: uniqueMemoIDs})
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
memosByID := make(map[int32]*store.Memo, len(memos))
|
|
for _, memo := range memos {
|
|
memosByID[memo.ID] = memo
|
|
}
|
|
return memosByID, nil
|
|
}
|