MM-43918: freemium limit for storage (#20225)

Summary
Adds an API end point to return storage usage

Ticket Link
https://mattermost.atlassian.net/browse/MM-43918
Этот коммит содержится в:
Ashish Bhate
2022-06-03 11:48:29 +05:30
коммит произвёл GitHub
родитель 1f6e2fe846
Коммит 8f912b697e
16 изменённых файлов: 261 добавлений и 5 удалений

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

@@ -3132,6 +3132,22 @@ func (s *TimerLayerFileInfoStore) GetFromMaster(id string) (*model.FileInfo, err
return result, err
}
func (s *TimerLayerFileInfoStore) GetStorageUsage(allowFromCache bool, includeDeleted bool) (int64, error) {
start := timemodule.Now()
result, err := s.FileInfoStore.GetStorageUsage(allowFromCache, includeDeleted)
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
if s.Root.Metrics != nil {
success := "false"
if err == nil {
success = "true"
}
s.Root.Metrics.ObserveStoreMethodDuration("FileInfoStore.GetStorageUsage", success, elapsed)
}
return result, err
}
func (s *TimerLayerFileInfoStore) GetWithOptions(page int, perPage int, opt *model.GetFileInfosOptions) ([]*model.FileInfo, error) {
start := timemodule.Now()