Implement POST /users/ids endpoint for APIv4 (#5274)
Этот коммит содержится в:
коммит произвёл
Corey Hulen
родитель
177589b1e2
Коммит
ccb0343828
@@ -808,8 +808,7 @@ func (us SqlUserStore) GetProfileByIds(userIds []string, allowFromCache bool) St
|
||||
result := StoreResult{}
|
||||
metrics := einterfaces.GetMetricsInterface()
|
||||
|
||||
var users []*model.User
|
||||
userMap := make(map[string]*model.User)
|
||||
users := []*model.User{}
|
||||
props := make(map[string]interface{})
|
||||
idQuery := ""
|
||||
remainingUserIds := make([]string, 0)
|
||||
@@ -818,13 +817,13 @@ func (us SqlUserStore) GetProfileByIds(userIds []string, allowFromCache bool) St
|
||||
for _, userId := range userIds {
|
||||
if cacheItem, ok := profileByIdsCache.Get(userId); ok {
|
||||
u := cacheItem.(*model.User)
|
||||
userMap[u.Id] = u
|
||||
users = append(users, u)
|
||||
} else {
|
||||
remainingUserIds = append(remainingUserIds, userId)
|
||||
}
|
||||
}
|
||||
if metrics != nil {
|
||||
metrics.AddMemCacheHitCounter("Profile By Ids", float64(len(userMap)))
|
||||
metrics.AddMemCacheHitCounter("Profile By Ids", float64(len(users)))
|
||||
metrics.AddMemCacheMissCounter("Profile By Ids", float64(len(remainingUserIds)))
|
||||
}
|
||||
} else {
|
||||
@@ -836,7 +835,7 @@ func (us SqlUserStore) GetProfileByIds(userIds []string, allowFromCache bool) St
|
||||
|
||||
// If everything came from the cache then just return
|
||||
if len(remainingUserIds) == 0 {
|
||||
result.Data = userMap
|
||||
result.Data = users
|
||||
storeChannel <- result
|
||||
close(storeChannel)
|
||||
return
|
||||
@@ -859,11 +858,10 @@ func (us SqlUserStore) GetProfileByIds(userIds []string, allowFromCache bool) St
|
||||
u.Password = ""
|
||||
u.AuthData = new(string)
|
||||
*u.AuthData = ""
|
||||
userMap[u.Id] = u
|
||||
profileByIdsCache.AddWithExpiresInSecs(u.Id, u, PROFILE_BY_IDS_CACHE_SEC)
|
||||
}
|
||||
|
||||
result.Data = userMap
|
||||
result.Data = users
|
||||
}
|
||||
|
||||
storeChannel <- result
|
||||
|
||||
Ссылка в новой задаче
Block a user