MCPcopy Create free account
hub / github.com/bytebase/bytebase / listAndCacheAllUsers

Method listAndCacheAllUsers

backend/store/principal.go:186–206  ·  view source on GitHub ↗

listAndCacheAllUsers is used for caching all users.

(ctx context.Context)

Source from the content-addressed store, hash-verified

184
185// listAndCacheAllUsers is used for caching all users.
186func (s *Store) listAndCacheAllUsers(ctx context.Context) error {
187 tx, err := s.GetDB().BeginTx(ctx, nil)
188 if err != nil {
189 return err
190 }
191 defer tx.Rollback()
192
193 users, err := listUserImpl(ctx, tx, &FindUserMessage{ShowDeleted: true})
194 if err != nil {
195 return err
196 }
197
198 if err := tx.Commit(); err != nil {
199 return err
200 }
201
202 for _, user := range users {
203 s.userEmailCache.Add(user.Email, user)
204 }
205 return nil
206}
207
208func listUserImpl(ctx context.Context, txn *sql.Tx, find *FindUserMessage) ([]*UserMessage, error) {
209 with := qb.Q()

Callers 1

GetUserByEmailMethod · 0.95

Calls 2

GetDBMethod · 0.95
listUserImplFunction · 0.85

Tested by

no test coverage detected