mirror of
https://github.com/mattermost/mattermost.git
synced 2025-02-25 18:55:24 -06:00
Removed the max/min family of functions (#28679)
They are in-built in Go now ```release-note NONE ```
This commit is contained in:
parent
4440ace6a9
commit
3db139f746
@ -1138,13 +1138,6 @@ func (a *App) getExplicitMentionsAndKeywords(c request.CTX, post *model.Post, ch
|
|||||||
return mentions, keywords
|
return mentions, keywords
|
||||||
}
|
}
|
||||||
|
|
||||||
func max(a, b int64) int64 {
|
|
||||||
if a < b {
|
|
||||||
return b
|
|
||||||
}
|
|
||||||
return a
|
|
||||||
}
|
|
||||||
|
|
||||||
func (a *App) userAllowsEmail(c request.CTX, user *model.User, channelMemberNotificationProps model.StringMap, post *model.Post) bool {
|
func (a *App) userAllowsEmail(c request.CTX, user *model.User, channelMemberNotificationProps model.StringMap, post *model.Post) bool {
|
||||||
// if user is a bot account or remote, then we do not send email
|
// if user is a bot account or remote, then we do not send email
|
||||||
if user.IsBot || user.IsRemote() {
|
if user.IsBot || user.IsRemote() {
|
||||||
|
@ -303,7 +303,7 @@ func New(sc ServiceConfig, options ...Option) (*PlatformService, error) {
|
|||||||
Name: "Status",
|
Name: "Status",
|
||||||
Size: model.StatusCacheSize,
|
Size: model.StatusCacheSize,
|
||||||
Striped: true,
|
Striped: true,
|
||||||
StripedBuckets: maxInt(runtime.NumCPU()-1, 1),
|
StripedBuckets: max(runtime.NumCPU()-1, 1),
|
||||||
DefaultExpiry: 30 * time.Minute,
|
DefaultExpiry: 30 * time.Minute,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -314,7 +314,7 @@ func New(sc ServiceConfig, options ...Option) (*PlatformService, error) {
|
|||||||
Name: "Session",
|
Name: "Session",
|
||||||
Size: model.SessionCacheSize,
|
Size: model.SessionCacheSize,
|
||||||
Striped: true,
|
Striped: true,
|
||||||
StripedBuckets: maxInt(runtime.NumCPU()-1, 1),
|
StripedBuckets: max(runtime.NumCPU()-1, 1),
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("could not create session cache: %w", err)
|
return nil, fmt.Errorf("could not create session cache: %w", err)
|
||||||
|
@ -14,13 +14,6 @@ func getKeyHash(key string) string {
|
|||||||
return base64.StdEncoding.EncodeToString(hash.Sum(nil))
|
return base64.StdEncoding.EncodeToString(hash.Sum(nil))
|
||||||
}
|
}
|
||||||
|
|
||||||
func maxInt(a, b int) int {
|
|
||||||
if a > b {
|
|
||||||
return a
|
|
||||||
}
|
|
||||||
return b
|
|
||||||
}
|
|
||||||
|
|
||||||
// allocateCacheTargets is used to fill target value types
|
// allocateCacheTargets is used to fill target value types
|
||||||
// for getting items from cache.
|
// for getting items from cache.
|
||||||
func allocateCacheTargets[T any](l int) []any {
|
func allocateCacheTargets[T any](l int) []any {
|
||||||
|
@ -152,7 +152,7 @@ func NewLocalCacheLayer(baseStore store.Store, metrics einterfaces.MetricsInterf
|
|||||||
DefaultExpiry: RoleCacheSec * time.Second,
|
DefaultExpiry: RoleCacheSec * time.Second,
|
||||||
InvalidateClusterEvent: model.ClusterEventInvalidateCacheForRoles,
|
InvalidateClusterEvent: model.ClusterEventInvalidateCacheForRoles,
|
||||||
Striped: true,
|
Striped: true,
|
||||||
StripedBuckets: maxInt(runtime.NumCPU()-1, 1),
|
StripedBuckets: max(runtime.NumCPU()-1, 1),
|
||||||
}); err != nil {
|
}); err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -336,7 +336,7 @@ func NewLocalCacheLayer(baseStore store.Store, metrics einterfaces.MetricsInterf
|
|||||||
DefaultExpiry: UserProfileByIDSec * time.Second,
|
DefaultExpiry: UserProfileByIDSec * time.Second,
|
||||||
InvalidateClusterEvent: model.ClusterEventInvalidateCacheForProfileByIds,
|
InvalidateClusterEvent: model.ClusterEventInvalidateCacheForProfileByIds,
|
||||||
Striped: true,
|
Striped: true,
|
||||||
StripedBuckets: maxInt(runtime.NumCPU()-1, 1),
|
StripedBuckets: max(runtime.NumCPU()-1, 1),
|
||||||
}); err != nil {
|
}); err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -394,13 +394,6 @@ func NewLocalCacheLayer(baseStore store.Store, metrics einterfaces.MetricsInterf
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func maxInt(a, b int) int {
|
|
||||||
if a > b {
|
|
||||||
return a
|
|
||||||
}
|
|
||||||
return b
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s LocalCacheStore) Reaction() store.ReactionStore {
|
func (s LocalCacheStore) Reaction() store.ReactionStore {
|
||||||
return s.reaction
|
return s.reaction
|
||||||
}
|
}
|
||||||
|
@ -818,7 +818,7 @@ func (s SqlSharedChannelStore) UpdateUserLastSyncAt(userID string, channelID str
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
updateAt := maxInt64(user.UpdateAt, user.LastPictureUpdate)
|
updateAt := max(user.UpdateAt, user.LastPictureUpdate)
|
||||||
|
|
||||||
query := s.getQueryBuilder().
|
query := s.getQueryBuilder().
|
||||||
Update("SharedChannelUsers AS scu").
|
Update("SharedChannelUsers AS scu").
|
||||||
|
@ -192,13 +192,6 @@ func trimInput(input string) string {
|
|||||||
return input
|
return input
|
||||||
}
|
}
|
||||||
|
|
||||||
func maxInt64(a, b int64) int64 {
|
|
||||||
if a > b {
|
|
||||||
return a
|
|
||||||
}
|
|
||||||
return b
|
|
||||||
}
|
|
||||||
|
|
||||||
// Adds backtiks to the column name for MySQL, this is required if
|
// Adds backtiks to the column name for MySQL, this is required if
|
||||||
// the column name is a reserved keyword.
|
// the column name is a reserved keyword.
|
||||||
//
|
//
|
||||||
|
@ -102,13 +102,6 @@ func (pluginAPI *mockPluginAPI) KVList(page, count int) ([]string, *model.AppErr
|
|||||||
return keys[start:end], nil
|
return keys[start:end], nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func min(a, b int) int {
|
|
||||||
if a < b {
|
|
||||||
return a
|
|
||||||
}
|
|
||||||
return b
|
|
||||||
}
|
|
||||||
|
|
||||||
func (pluginAPI *mockPluginAPI) KVSetWithOptions(key string, value []byte, options model.PluginKVSetOptions) (bool, *model.AppError) {
|
func (pluginAPI *mockPluginAPI) KVSetWithOptions(key string, value []byte, options model.PluginKVSetOptions) (bool, *model.AppError) {
|
||||||
pluginAPI.lock.Lock()
|
pluginAPI.lock.Lock()
|
||||||
defer pluginAPI.lock.Unlock()
|
defer pluginAPI.lock.Unlock()
|
||||||
|
Loading…
Reference in New Issue
Block a user