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
Этот коммит содержится в:
Harrison Healey
2019-06-27 09:37:03 -04:00
коммит произвёл GitHub
родитель 89a41dc381
Коммит 4b96437370
12 изменённых файлов: 176 добавлений и 47 удалений

Просмотреть файл

@@ -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 {