MM-16477 Add api to get users modified since a given time (#11406)
* MM-16477 Add api to get users modified since a given time * Address feedback
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
89a41dc381
Коммит
4b96437370
@@ -10,6 +10,7 @@ import (
|
||||
"sort"
|
||||
"strings"
|
||||
|
||||
"github.com/Masterminds/squirrel"
|
||||
sq "github.com/Masterminds/squirrel"
|
||||
"github.com/mattermost/gorp"
|
||||
|
||||
@@ -846,8 +847,12 @@ func (us SqlUserStore) GetNewUsersForTeam(teamId string, offset, limit int, view
|
||||
return users, nil
|
||||
}
|
||||
|
||||
func (us SqlUserStore) GetProfileByIds(userIds []string, allowFromCache bool, viewRestrictions *model.ViewUsersRestrictions) store.StoreChannel {
|
||||
func (us SqlUserStore) GetProfileByIds(userIds []string, options *store.UserGetByIdsOpts, allowFromCache bool) store.StoreChannel {
|
||||
return store.Do(func(result *store.StoreResult) {
|
||||
if options == nil {
|
||||
options = &store.UserGetByIdsOpts{}
|
||||
}
|
||||
|
||||
users := []*model.User{}
|
||||
remainingUserIds := make([]string, 0)
|
||||
|
||||
@@ -856,7 +861,10 @@ func (us SqlUserStore) GetProfileByIds(userIds []string, allowFromCache bool, vi
|
||||
if cacheItem, ok := profileByIdsCache.Get(userId); ok {
|
||||
u := &model.User{}
|
||||
*u = *cacheItem.(*model.User)
|
||||
users = append(users, u)
|
||||
|
||||
if options.Since == 0 || u.UpdateAt > options.Since {
|
||||
users = append(users, u)
|
||||
}
|
||||
} else {
|
||||
remainingUserIds = append(remainingUserIds, userId)
|
||||
}
|
||||
@@ -884,7 +892,13 @@ func (us SqlUserStore) GetProfileByIds(userIds []string, allowFromCache bool, vi
|
||||
}).
|
||||
OrderBy("u.Username ASC")
|
||||
|
||||
query = applyViewRestrictionsFilter(query, viewRestrictions, true)
|
||||
if options.Since > 0 {
|
||||
query = query.Where(squirrel.Gt(map[string]interface{}{
|
||||
"u.UpdateAt": options.Since,
|
||||
}))
|
||||
}
|
||||
|
||||
query = applyViewRestrictionsFilter(query, options.ViewRestrictions, true)
|
||||
|
||||
queryString, args, err := query.ToSql()
|
||||
if err != nil {
|
||||
|
||||
Ссылка в новой задаче
Block a user