mirror of
https://github.com/mattermost/mattermost.git
synced 2026-02-18 18:18:23 -05:00
* MM-31094: Adds tooling to develop and test using a MySQL instance with replication lag. Adds some lazy lookups to fallback to master if results are not found.
* MM-31094: Removes mysql-read-replica from default docker services.
* MM-31094: Switches (store..SessionStore).Get and (store.TeamStore).GetMember to using context.Context.
* MM-31094: Updates (store.UsersStore).Get to use context.
* MM-31094: Updates (store.PostStore).Get to use context.
* MM-31094: Removes feature flag and config setting.
* MM-31094: Rolls back some master reads.
* MM-31094: Rolls a non-cache read.
* MM-31094: Removes feature flag from the store.
* MM-31094: Removes unused constant and struct field.
* MM-31094: Removes some old feature flag references.
* MM-31094: Fixes some tests.
* MM-31094: App layers fix.
* MM-31094: Fixes mocks.
* MM-31094: Don't reparse flag.
* MM-31094: No reparse.
* MM-31094: Removed unused FeatureFlags field.
* MM-31094: Removes unnecessary feature flags variable declarations.
* MM-31094: Fixes copy-paste error.
* MM-31094: Fixes logical error.
* MM-30194: Removes test method from store.
* Revert "MM-30194: Removes test method from store."
This reverts commit d5a6e8529b.
* MM-31094: Conforming to make's strange syntax.
* MM-31094: Configures helper for read replica with option.
* MM-31094: Adds some missing ctx's.
* MM-31094: WIP
* MM-31094: Updates test names.
* MM-31094: WIP
* MM-31094: Removes unnecessary master reads.
* MM-31094: ID case changes out of scope.
* MM-31094: Removes unused context.
* MM-31094: Switches to a helper. Removes some var naming changes. Fixes a merge error.
* MM-31094: Removes SQLITE db driver ref.
* MM-31094: Layer generate fix.
* MM-31094: Removes unnecessary changes.
* MM-31094: Moves test method.
* MM-31094: Re-add previous fix.
* MM-31094: Removes make command for dev.
* MM-31094: Fix for login.
Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
9253 lines
267 KiB
Go
9253 lines
267 KiB
Go
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
|
// See LICENSE.txt for license information.
|
|
|
|
// Code generated by "make store-layers"
|
|
// DO NOT EDIT
|
|
|
|
package timerlayer
|
|
|
|
import (
|
|
"context"
|
|
timemodule "time"
|
|
|
|
"github.com/mattermost/mattermost-server/v5/einterfaces"
|
|
"github.com/mattermost/mattermost-server/v5/model"
|
|
"github.com/mattermost/mattermost-server/v5/store"
|
|
)
|
|
|
|
type TimerLayer struct {
|
|
store.Store
|
|
Metrics einterfaces.MetricsInterface
|
|
AuditStore store.AuditStore
|
|
BotStore store.BotStore
|
|
ChannelStore store.ChannelStore
|
|
ChannelMemberHistoryStore store.ChannelMemberHistoryStore
|
|
ClusterDiscoveryStore store.ClusterDiscoveryStore
|
|
CommandStore store.CommandStore
|
|
CommandWebhookStore store.CommandWebhookStore
|
|
ComplianceStore store.ComplianceStore
|
|
EmojiStore store.EmojiStore
|
|
FileInfoStore store.FileInfoStore
|
|
GroupStore store.GroupStore
|
|
JobStore store.JobStore
|
|
LicenseStore store.LicenseStore
|
|
LinkMetadataStore store.LinkMetadataStore
|
|
OAuthStore store.OAuthStore
|
|
PluginStore store.PluginStore
|
|
PostStore store.PostStore
|
|
PreferenceStore store.PreferenceStore
|
|
ProductNoticesStore store.ProductNoticesStore
|
|
ReactionStore store.ReactionStore
|
|
RoleStore store.RoleStore
|
|
SchemeStore store.SchemeStore
|
|
SessionStore store.SessionStore
|
|
StatusStore store.StatusStore
|
|
SystemStore store.SystemStore
|
|
TeamStore store.TeamStore
|
|
TermsOfServiceStore store.TermsOfServiceStore
|
|
ThreadStore store.ThreadStore
|
|
TokenStore store.TokenStore
|
|
UploadSessionStore store.UploadSessionStore
|
|
UserStore store.UserStore
|
|
UserAccessTokenStore store.UserAccessTokenStore
|
|
UserTermsOfServiceStore store.UserTermsOfServiceStore
|
|
WebhookStore store.WebhookStore
|
|
}
|
|
|
|
func (s *TimerLayer) Audit() store.AuditStore {
|
|
return s.AuditStore
|
|
}
|
|
|
|
func (s *TimerLayer) Bot() store.BotStore {
|
|
return s.BotStore
|
|
}
|
|
|
|
func (s *TimerLayer) Channel() store.ChannelStore {
|
|
return s.ChannelStore
|
|
}
|
|
|
|
func (s *TimerLayer) ChannelMemberHistory() store.ChannelMemberHistoryStore {
|
|
return s.ChannelMemberHistoryStore
|
|
}
|
|
|
|
func (s *TimerLayer) ClusterDiscovery() store.ClusterDiscoveryStore {
|
|
return s.ClusterDiscoveryStore
|
|
}
|
|
|
|
func (s *TimerLayer) Command() store.CommandStore {
|
|
return s.CommandStore
|
|
}
|
|
|
|
func (s *TimerLayer) CommandWebhook() store.CommandWebhookStore {
|
|
return s.CommandWebhookStore
|
|
}
|
|
|
|
func (s *TimerLayer) Compliance() store.ComplianceStore {
|
|
return s.ComplianceStore
|
|
}
|
|
|
|
func (s *TimerLayer) Emoji() store.EmojiStore {
|
|
return s.EmojiStore
|
|
}
|
|
|
|
func (s *TimerLayer) FileInfo() store.FileInfoStore {
|
|
return s.FileInfoStore
|
|
}
|
|
|
|
func (s *TimerLayer) Group() store.GroupStore {
|
|
return s.GroupStore
|
|
}
|
|
|
|
func (s *TimerLayer) Job() store.JobStore {
|
|
return s.JobStore
|
|
}
|
|
|
|
func (s *TimerLayer) License() store.LicenseStore {
|
|
return s.LicenseStore
|
|
}
|
|
|
|
func (s *TimerLayer) LinkMetadata() store.LinkMetadataStore {
|
|
return s.LinkMetadataStore
|
|
}
|
|
|
|
func (s *TimerLayer) OAuth() store.OAuthStore {
|
|
return s.OAuthStore
|
|
}
|
|
|
|
func (s *TimerLayer) Plugin() store.PluginStore {
|
|
return s.PluginStore
|
|
}
|
|
|
|
func (s *TimerLayer) Post() store.PostStore {
|
|
return s.PostStore
|
|
}
|
|
|
|
func (s *TimerLayer) Preference() store.PreferenceStore {
|
|
return s.PreferenceStore
|
|
}
|
|
|
|
func (s *TimerLayer) ProductNotices() store.ProductNoticesStore {
|
|
return s.ProductNoticesStore
|
|
}
|
|
|
|
func (s *TimerLayer) Reaction() store.ReactionStore {
|
|
return s.ReactionStore
|
|
}
|
|
|
|
func (s *TimerLayer) Role() store.RoleStore {
|
|
return s.RoleStore
|
|
}
|
|
|
|
func (s *TimerLayer) Scheme() store.SchemeStore {
|
|
return s.SchemeStore
|
|
}
|
|
|
|
func (s *TimerLayer) Session() store.SessionStore {
|
|
return s.SessionStore
|
|
}
|
|
|
|
func (s *TimerLayer) Status() store.StatusStore {
|
|
return s.StatusStore
|
|
}
|
|
|
|
func (s *TimerLayer) System() store.SystemStore {
|
|
return s.SystemStore
|
|
}
|
|
|
|
func (s *TimerLayer) Team() store.TeamStore {
|
|
return s.TeamStore
|
|
}
|
|
|
|
func (s *TimerLayer) TermsOfService() store.TermsOfServiceStore {
|
|
return s.TermsOfServiceStore
|
|
}
|
|
|
|
func (s *TimerLayer) Thread() store.ThreadStore {
|
|
return s.ThreadStore
|
|
}
|
|
|
|
func (s *TimerLayer) Token() store.TokenStore {
|
|
return s.TokenStore
|
|
}
|
|
|
|
func (s *TimerLayer) UploadSession() store.UploadSessionStore {
|
|
return s.UploadSessionStore
|
|
}
|
|
|
|
func (s *TimerLayer) User() store.UserStore {
|
|
return s.UserStore
|
|
}
|
|
|
|
func (s *TimerLayer) UserAccessToken() store.UserAccessTokenStore {
|
|
return s.UserAccessTokenStore
|
|
}
|
|
|
|
func (s *TimerLayer) UserTermsOfService() store.UserTermsOfServiceStore {
|
|
return s.UserTermsOfServiceStore
|
|
}
|
|
|
|
func (s *TimerLayer) Webhook() store.WebhookStore {
|
|
return s.WebhookStore
|
|
}
|
|
|
|
type TimerLayerAuditStore struct {
|
|
store.AuditStore
|
|
Root *TimerLayer
|
|
}
|
|
|
|
type TimerLayerBotStore struct {
|
|
store.BotStore
|
|
Root *TimerLayer
|
|
}
|
|
|
|
type TimerLayerChannelStore struct {
|
|
store.ChannelStore
|
|
Root *TimerLayer
|
|
}
|
|
|
|
type TimerLayerChannelMemberHistoryStore struct {
|
|
store.ChannelMemberHistoryStore
|
|
Root *TimerLayer
|
|
}
|
|
|
|
type TimerLayerClusterDiscoveryStore struct {
|
|
store.ClusterDiscoveryStore
|
|
Root *TimerLayer
|
|
}
|
|
|
|
type TimerLayerCommandStore struct {
|
|
store.CommandStore
|
|
Root *TimerLayer
|
|
}
|
|
|
|
type TimerLayerCommandWebhookStore struct {
|
|
store.CommandWebhookStore
|
|
Root *TimerLayer
|
|
}
|
|
|
|
type TimerLayerComplianceStore struct {
|
|
store.ComplianceStore
|
|
Root *TimerLayer
|
|
}
|
|
|
|
type TimerLayerEmojiStore struct {
|
|
store.EmojiStore
|
|
Root *TimerLayer
|
|
}
|
|
|
|
type TimerLayerFileInfoStore struct {
|
|
store.FileInfoStore
|
|
Root *TimerLayer
|
|
}
|
|
|
|
type TimerLayerGroupStore struct {
|
|
store.GroupStore
|
|
Root *TimerLayer
|
|
}
|
|
|
|
type TimerLayerJobStore struct {
|
|
store.JobStore
|
|
Root *TimerLayer
|
|
}
|
|
|
|
type TimerLayerLicenseStore struct {
|
|
store.LicenseStore
|
|
Root *TimerLayer
|
|
}
|
|
|
|
type TimerLayerLinkMetadataStore struct {
|
|
store.LinkMetadataStore
|
|
Root *TimerLayer
|
|
}
|
|
|
|
type TimerLayerOAuthStore struct {
|
|
store.OAuthStore
|
|
Root *TimerLayer
|
|
}
|
|
|
|
type TimerLayerPluginStore struct {
|
|
store.PluginStore
|
|
Root *TimerLayer
|
|
}
|
|
|
|
type TimerLayerPostStore struct {
|
|
store.PostStore
|
|
Root *TimerLayer
|
|
}
|
|
|
|
type TimerLayerPreferenceStore struct {
|
|
store.PreferenceStore
|
|
Root *TimerLayer
|
|
}
|
|
|
|
type TimerLayerProductNoticesStore struct {
|
|
store.ProductNoticesStore
|
|
Root *TimerLayer
|
|
}
|
|
|
|
type TimerLayerReactionStore struct {
|
|
store.ReactionStore
|
|
Root *TimerLayer
|
|
}
|
|
|
|
type TimerLayerRoleStore struct {
|
|
store.RoleStore
|
|
Root *TimerLayer
|
|
}
|
|
|
|
type TimerLayerSchemeStore struct {
|
|
store.SchemeStore
|
|
Root *TimerLayer
|
|
}
|
|
|
|
type TimerLayerSessionStore struct {
|
|
store.SessionStore
|
|
Root *TimerLayer
|
|
}
|
|
|
|
type TimerLayerStatusStore struct {
|
|
store.StatusStore
|
|
Root *TimerLayer
|
|
}
|
|
|
|
type TimerLayerSystemStore struct {
|
|
store.SystemStore
|
|
Root *TimerLayer
|
|
}
|
|
|
|
type TimerLayerTeamStore struct {
|
|
store.TeamStore
|
|
Root *TimerLayer
|
|
}
|
|
|
|
type TimerLayerTermsOfServiceStore struct {
|
|
store.TermsOfServiceStore
|
|
Root *TimerLayer
|
|
}
|
|
|
|
type TimerLayerThreadStore struct {
|
|
store.ThreadStore
|
|
Root *TimerLayer
|
|
}
|
|
|
|
type TimerLayerTokenStore struct {
|
|
store.TokenStore
|
|
Root *TimerLayer
|
|
}
|
|
|
|
type TimerLayerUploadSessionStore struct {
|
|
store.UploadSessionStore
|
|
Root *TimerLayer
|
|
}
|
|
|
|
type TimerLayerUserStore struct {
|
|
store.UserStore
|
|
Root *TimerLayer
|
|
}
|
|
|
|
type TimerLayerUserAccessTokenStore struct {
|
|
store.UserAccessTokenStore
|
|
Root *TimerLayer
|
|
}
|
|
|
|
type TimerLayerUserTermsOfServiceStore struct {
|
|
store.UserTermsOfServiceStore
|
|
Root *TimerLayer
|
|
}
|
|
|
|
type TimerLayerWebhookStore struct {
|
|
store.WebhookStore
|
|
Root *TimerLayer
|
|
}
|
|
|
|
func (s *TimerLayerAuditStore) Get(user_id string, offset int, limit int) (model.Audits, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.AuditStore.Get(user_id, offset, limit)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("AuditStore.Get", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerAuditStore) PermanentDeleteByUser(userId string) error {
|
|
start := timemodule.Now()
|
|
|
|
err := s.AuditStore.PermanentDeleteByUser(userId)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("AuditStore.PermanentDeleteByUser", success, elapsed)
|
|
}
|
|
return err
|
|
}
|
|
|
|
func (s *TimerLayerAuditStore) Save(audit *model.Audit) error {
|
|
start := timemodule.Now()
|
|
|
|
err := s.AuditStore.Save(audit)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("AuditStore.Save", success, elapsed)
|
|
}
|
|
return err
|
|
}
|
|
|
|
func (s *TimerLayerBotStore) Get(userId string, includeDeleted bool) (*model.Bot, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.BotStore.Get(userId, 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("BotStore.Get", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerBotStore) GetAll(options *model.BotGetOptions) ([]*model.Bot, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.BotStore.GetAll(options)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("BotStore.GetAll", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerBotStore) PermanentDelete(userId string) error {
|
|
start := timemodule.Now()
|
|
|
|
err := s.BotStore.PermanentDelete(userId)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("BotStore.PermanentDelete", success, elapsed)
|
|
}
|
|
return err
|
|
}
|
|
|
|
func (s *TimerLayerBotStore) Save(bot *model.Bot) (*model.Bot, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.BotStore.Save(bot)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("BotStore.Save", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerBotStore) Update(bot *model.Bot) (*model.Bot, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.BotStore.Update(bot)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("BotStore.Update", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerChannelStore) AnalyticsDeletedTypeCount(teamID string, channelType string) (int64, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.ChannelStore.AnalyticsDeletedTypeCount(teamID, channelType)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.AnalyticsDeletedTypeCount", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerChannelStore) AnalyticsTypeCount(teamID string, channelType string) (int64, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.ChannelStore.AnalyticsTypeCount(teamID, channelType)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.AnalyticsTypeCount", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerChannelStore) AutocompleteInTeam(teamID string, term string, includeDeleted bool) (*model.ChannelList, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.ChannelStore.AutocompleteInTeam(teamID, term, 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("ChannelStore.AutocompleteInTeam", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerChannelStore) AutocompleteInTeamForSearch(teamID string, userId string, term string, includeDeleted bool) (*model.ChannelList, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.ChannelStore.AutocompleteInTeamForSearch(teamID, userId, term, 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("ChannelStore.AutocompleteInTeamForSearch", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerChannelStore) ClearAllCustomRoleAssignments() error {
|
|
start := timemodule.Now()
|
|
|
|
err := s.ChannelStore.ClearAllCustomRoleAssignments()
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.ClearAllCustomRoleAssignments", success, elapsed)
|
|
}
|
|
return err
|
|
}
|
|
|
|
func (s *TimerLayerChannelStore) ClearCaches() {
|
|
start := timemodule.Now()
|
|
|
|
s.ChannelStore.ClearCaches()
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if true {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.ClearCaches", success, elapsed)
|
|
}
|
|
}
|
|
|
|
func (s *TimerLayerChannelStore) ClearSidebarOnTeamLeave(userId string, teamID string) error {
|
|
start := timemodule.Now()
|
|
|
|
err := s.ChannelStore.ClearSidebarOnTeamLeave(userId, teamID)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.ClearSidebarOnTeamLeave", success, elapsed)
|
|
}
|
|
return err
|
|
}
|
|
|
|
func (s *TimerLayerChannelStore) CountPostsAfter(channelID string, timestamp int64, userId string) (int, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.ChannelStore.CountPostsAfter(channelID, timestamp, userId)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.CountPostsAfter", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerChannelStore) CreateDirectChannel(userId *model.User, otherUserId *model.User) (*model.Channel, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.ChannelStore.CreateDirectChannel(userId, otherUserId)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.CreateDirectChannel", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerChannelStore) CreateInitialSidebarCategories(userId string, teamID string) (*model.OrderedSidebarCategories, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.ChannelStore.CreateInitialSidebarCategories(userId, teamID)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.CreateInitialSidebarCategories", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerChannelStore) CreateSidebarCategory(userId string, teamID string, newCategory *model.SidebarCategoryWithChannels) (*model.SidebarCategoryWithChannels, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.ChannelStore.CreateSidebarCategory(userId, teamID, newCategory)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.CreateSidebarCategory", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerChannelStore) Delete(channelID string, time int64) error {
|
|
start := timemodule.Now()
|
|
|
|
err := s.ChannelStore.Delete(channelID, time)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.Delete", success, elapsed)
|
|
}
|
|
return err
|
|
}
|
|
|
|
func (s *TimerLayerChannelStore) DeleteSidebarCategory(categoryID string) error {
|
|
start := timemodule.Now()
|
|
|
|
err := s.ChannelStore.DeleteSidebarCategory(categoryID)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.DeleteSidebarCategory", success, elapsed)
|
|
}
|
|
return err
|
|
}
|
|
|
|
func (s *TimerLayerChannelStore) DeleteSidebarChannelsByPreferences(preferences *model.Preferences) error {
|
|
start := timemodule.Now()
|
|
|
|
err := s.ChannelStore.DeleteSidebarChannelsByPreferences(preferences)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.DeleteSidebarChannelsByPreferences", success, elapsed)
|
|
}
|
|
return err
|
|
}
|
|
|
|
func (s *TimerLayerChannelStore) Get(id string, allowFromCache bool) (*model.Channel, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.ChannelStore.Get(id, allowFromCache)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.Get", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerChannelStore) GetAll(teamID string) ([]*model.Channel, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.ChannelStore.GetAll(teamID)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.GetAll", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerChannelStore) GetAllChannelMembersForUser(userId string, allowFromCache bool, includeDeleted bool) (map[string]string, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.ChannelStore.GetAllChannelMembersForUser(userId, 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("ChannelStore.GetAllChannelMembersForUser", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerChannelStore) GetAllChannelMembersNotifyPropsForChannel(channelID string, allowFromCache bool) (map[string]model.StringMap, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.ChannelStore.GetAllChannelMembersNotifyPropsForChannel(channelID, allowFromCache)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.GetAllChannelMembersNotifyPropsForChannel", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerChannelStore) GetAllChannels(page int, perPage int, opts store.ChannelSearchOpts) (*model.ChannelListWithTeamData, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.ChannelStore.GetAllChannels(page, perPage, opts)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.GetAllChannels", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerChannelStore) GetAllChannelsCount(opts store.ChannelSearchOpts) (int64, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.ChannelStore.GetAllChannelsCount(opts)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.GetAllChannelsCount", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerChannelStore) GetAllChannelsForExportAfter(limit int, afterID string) ([]*model.ChannelForExport, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.ChannelStore.GetAllChannelsForExportAfter(limit, afterID)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.GetAllChannelsForExportAfter", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerChannelStore) GetAllDirectChannelsForExportAfter(limit int, afterID string) ([]*model.DirectChannelForExport, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.ChannelStore.GetAllDirectChannelsForExportAfter(limit, afterID)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.GetAllDirectChannelsForExportAfter", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerChannelStore) GetByName(team_id string, name string, allowFromCache bool) (*model.Channel, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.ChannelStore.GetByName(team_id, name, allowFromCache)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.GetByName", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerChannelStore) GetByNameIncludeDeleted(team_id string, name string, allowFromCache bool) (*model.Channel, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.ChannelStore.GetByNameIncludeDeleted(team_id, name, allowFromCache)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.GetByNameIncludeDeleted", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerChannelStore) GetByNames(team_id string, names []string, allowFromCache bool) ([]*model.Channel, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.ChannelStore.GetByNames(team_id, names, allowFromCache)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.GetByNames", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerChannelStore) GetChannelCounts(teamID string, userId string) (*model.ChannelCounts, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.ChannelStore.GetChannelCounts(teamID, userId)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.GetChannelCounts", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerChannelStore) GetChannelMembersForExport(userId string, teamID string) ([]*model.ChannelMemberForExport, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.ChannelStore.GetChannelMembersForExport(userId, teamID)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.GetChannelMembersForExport", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerChannelStore) GetChannelMembersTimezones(channelID string) ([]model.StringMap, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.ChannelStore.GetChannelMembersTimezones(channelID)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.GetChannelMembersTimezones", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerChannelStore) GetChannelUnread(channelID string, userId string) (*model.ChannelUnread, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.ChannelStore.GetChannelUnread(channelID, userId)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.GetChannelUnread", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerChannelStore) GetChannels(teamID string, userId string, includeDeleted bool, lastDeleteAt int) (*model.ChannelList, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.ChannelStore.GetChannels(teamID, userId, includeDeleted, lastDeleteAt)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.GetChannels", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerChannelStore) GetChannelsBatchForIndexing(startTime int64, endTime int64, limit int) ([]*model.Channel, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.ChannelStore.GetChannelsBatchForIndexing(startTime, endTime, limit)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.GetChannelsBatchForIndexing", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerChannelStore) GetChannelsByIds(channelIds []string, includeDeleted bool) ([]*model.Channel, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.ChannelStore.GetChannelsByIds(channelIds, 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("ChannelStore.GetChannelsByIds", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerChannelStore) GetChannelsByScheme(schemeID string, offset int, limit int) (model.ChannelList, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.ChannelStore.GetChannelsByScheme(schemeID, offset, limit)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.GetChannelsByScheme", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerChannelStore) GetDeleted(team_id string, offset int, limit int, userId string) (*model.ChannelList, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.ChannelStore.GetDeleted(team_id, offset, limit, userId)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.GetDeleted", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerChannelStore) GetDeletedByName(team_id string, name string) (*model.Channel, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.ChannelStore.GetDeletedByName(team_id, name)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.GetDeletedByName", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerChannelStore) GetForPost(postID string) (*model.Channel, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.ChannelStore.GetForPost(postID)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.GetForPost", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerChannelStore) GetFromMaster(id string) (*model.Channel, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.ChannelStore.GetFromMaster(id)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.GetFromMaster", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerChannelStore) GetGuestCount(channelID string, allowFromCache bool) (int64, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.ChannelStore.GetGuestCount(channelID, allowFromCache)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.GetGuestCount", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerChannelStore) GetMember(channelID string, userId string) (*model.ChannelMember, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.ChannelStore.GetMember(channelID, userId)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.GetMember", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerChannelStore) GetMemberCount(channelID string, allowFromCache bool) (int64, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.ChannelStore.GetMemberCount(channelID, allowFromCache)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.GetMemberCount", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerChannelStore) GetMemberCountFromCache(channelID string) int64 {
|
|
start := timemodule.Now()
|
|
|
|
result := s.ChannelStore.GetMemberCountFromCache(channelID)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if true {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.GetMemberCountFromCache", success, elapsed)
|
|
}
|
|
return result
|
|
}
|
|
|
|
func (s *TimerLayerChannelStore) GetMemberCountsByGroup(channelID string, includeTimezones bool) ([]*model.ChannelMemberCountByGroup, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.ChannelStore.GetMemberCountsByGroup(channelID, includeTimezones)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.GetMemberCountsByGroup", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerChannelStore) GetMemberForPost(postID string, userId string) (*model.ChannelMember, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.ChannelStore.GetMemberForPost(postID, userId)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.GetMemberForPost", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerChannelStore) GetMembers(channelID string, offset int, limit int) (*model.ChannelMembers, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.ChannelStore.GetMembers(channelID, offset, limit)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.GetMembers", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerChannelStore) GetMembersByChannelIds(channelIds []string, userId string) (*model.ChannelMembers, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.ChannelStore.GetMembersByChannelIds(channelIds, userId)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.GetMembersByChannelIds", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerChannelStore) GetMembersByIds(channelID string, userIds []string) (*model.ChannelMembers, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.ChannelStore.GetMembersByIds(channelID, userIds)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.GetMembersByIds", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerChannelStore) GetMembersForUser(teamID string, userId string) (*model.ChannelMembers, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.ChannelStore.GetMembersForUser(teamID, userId)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.GetMembersForUser", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerChannelStore) GetMembersForUserWithPagination(teamID string, userId string, page int, perPage int) (*model.ChannelMembers, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.ChannelStore.GetMembersForUserWithPagination(teamID, userId, page, perPage)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.GetMembersForUserWithPagination", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerChannelStore) GetMoreChannels(teamID string, userId string, offset int, limit int) (*model.ChannelList, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.ChannelStore.GetMoreChannels(teamID, userId, offset, limit)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.GetMoreChannels", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerChannelStore) GetPinnedPostCount(channelID string, allowFromCache bool) (int64, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.ChannelStore.GetPinnedPostCount(channelID, allowFromCache)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.GetPinnedPostCount", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerChannelStore) GetPinnedPosts(channelID string) (*model.PostList, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.ChannelStore.GetPinnedPosts(channelID)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.GetPinnedPosts", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerChannelStore) GetPrivateChannelsForTeam(teamID string, offset int, limit int) (*model.ChannelList, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.ChannelStore.GetPrivateChannelsForTeam(teamID, offset, limit)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.GetPrivateChannelsForTeam", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerChannelStore) GetPublicChannelsByIdsForTeam(teamID string, channelIds []string) (*model.ChannelList, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.ChannelStore.GetPublicChannelsByIdsForTeam(teamID, channelIds)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.GetPublicChannelsByIdsForTeam", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerChannelStore) GetPublicChannelsForTeam(teamID string, offset int, limit int) (*model.ChannelList, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.ChannelStore.GetPublicChannelsForTeam(teamID, offset, limit)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.GetPublicChannelsForTeam", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerChannelStore) GetSidebarCategories(userId string, teamID string) (*model.OrderedSidebarCategories, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.ChannelStore.GetSidebarCategories(userId, teamID)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.GetSidebarCategories", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerChannelStore) GetSidebarCategory(categoryID string) (*model.SidebarCategoryWithChannels, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.ChannelStore.GetSidebarCategory(categoryID)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.GetSidebarCategory", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerChannelStore) GetSidebarCategoryOrder(userId string, teamID string) ([]string, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.ChannelStore.GetSidebarCategoryOrder(userId, teamID)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.GetSidebarCategoryOrder", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerChannelStore) GetTeamChannels(teamID string) (*model.ChannelList, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.ChannelStore.GetTeamChannels(teamID)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.GetTeamChannels", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerChannelStore) GroupSyncedChannelCount() (int64, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.ChannelStore.GroupSyncedChannelCount()
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.GroupSyncedChannelCount", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerChannelStore) IncrementMentionCount(channelID string, userId string, updateThreads bool) error {
|
|
start := timemodule.Now()
|
|
|
|
err := s.ChannelStore.IncrementMentionCount(channelID, userId, updateThreads)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.IncrementMentionCount", success, elapsed)
|
|
}
|
|
return err
|
|
}
|
|
|
|
func (s *TimerLayerChannelStore) InvalidateAllChannelMembersForUser(userId string) {
|
|
start := timemodule.Now()
|
|
|
|
s.ChannelStore.InvalidateAllChannelMembersForUser(userId)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if true {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.InvalidateAllChannelMembersForUser", success, elapsed)
|
|
}
|
|
}
|
|
|
|
func (s *TimerLayerChannelStore) InvalidateCacheForChannelMembersNotifyProps(channelID string) {
|
|
start := timemodule.Now()
|
|
|
|
s.ChannelStore.InvalidateCacheForChannelMembersNotifyProps(channelID)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if true {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.InvalidateCacheForChannelMembersNotifyProps", success, elapsed)
|
|
}
|
|
}
|
|
|
|
func (s *TimerLayerChannelStore) InvalidateChannel(id string) {
|
|
start := timemodule.Now()
|
|
|
|
s.ChannelStore.InvalidateChannel(id)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if true {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.InvalidateChannel", success, elapsed)
|
|
}
|
|
}
|
|
|
|
func (s *TimerLayerChannelStore) InvalidateChannelByName(teamID string, name string) {
|
|
start := timemodule.Now()
|
|
|
|
s.ChannelStore.InvalidateChannelByName(teamID, name)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if true {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.InvalidateChannelByName", success, elapsed)
|
|
}
|
|
}
|
|
|
|
func (s *TimerLayerChannelStore) InvalidateGuestCount(channelID string) {
|
|
start := timemodule.Now()
|
|
|
|
s.ChannelStore.InvalidateGuestCount(channelID)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if true {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.InvalidateGuestCount", success, elapsed)
|
|
}
|
|
}
|
|
|
|
func (s *TimerLayerChannelStore) InvalidateMemberCount(channelID string) {
|
|
start := timemodule.Now()
|
|
|
|
s.ChannelStore.InvalidateMemberCount(channelID)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if true {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.InvalidateMemberCount", success, elapsed)
|
|
}
|
|
}
|
|
|
|
func (s *TimerLayerChannelStore) InvalidatePinnedPostCount(channelID string) {
|
|
start := timemodule.Now()
|
|
|
|
s.ChannelStore.InvalidatePinnedPostCount(channelID)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if true {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.InvalidatePinnedPostCount", success, elapsed)
|
|
}
|
|
}
|
|
|
|
func (s *TimerLayerChannelStore) IsUserInChannelUseCache(userId string, channelID string) bool {
|
|
start := timemodule.Now()
|
|
|
|
result := s.ChannelStore.IsUserInChannelUseCache(userId, channelID)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if true {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.IsUserInChannelUseCache", success, elapsed)
|
|
}
|
|
return result
|
|
}
|
|
|
|
func (s *TimerLayerChannelStore) MigrateChannelMembers(fromChannelId string, fromUserId string) (map[string]string, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.ChannelStore.MigrateChannelMembers(fromChannelId, fromUserId)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.MigrateChannelMembers", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerChannelStore) MigratePublicChannels() error {
|
|
start := timemodule.Now()
|
|
|
|
err := s.ChannelStore.MigratePublicChannels()
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.MigratePublicChannels", success, elapsed)
|
|
}
|
|
return err
|
|
}
|
|
|
|
func (s *TimerLayerChannelStore) PermanentDelete(channelID string) error {
|
|
start := timemodule.Now()
|
|
|
|
err := s.ChannelStore.PermanentDelete(channelID)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.PermanentDelete", success, elapsed)
|
|
}
|
|
return err
|
|
}
|
|
|
|
func (s *TimerLayerChannelStore) PermanentDeleteByTeam(teamID string) error {
|
|
start := timemodule.Now()
|
|
|
|
err := s.ChannelStore.PermanentDeleteByTeam(teamID)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.PermanentDeleteByTeam", success, elapsed)
|
|
}
|
|
return err
|
|
}
|
|
|
|
func (s *TimerLayerChannelStore) PermanentDeleteMembersByChannel(channelID string) error {
|
|
start := timemodule.Now()
|
|
|
|
err := s.ChannelStore.PermanentDeleteMembersByChannel(channelID)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.PermanentDeleteMembersByChannel", success, elapsed)
|
|
}
|
|
return err
|
|
}
|
|
|
|
func (s *TimerLayerChannelStore) PermanentDeleteMembersByUser(userId string) error {
|
|
start := timemodule.Now()
|
|
|
|
err := s.ChannelStore.PermanentDeleteMembersByUser(userId)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.PermanentDeleteMembersByUser", success, elapsed)
|
|
}
|
|
return err
|
|
}
|
|
|
|
func (s *TimerLayerChannelStore) RemoveAllDeactivatedMembers(channelID string) error {
|
|
start := timemodule.Now()
|
|
|
|
err := s.ChannelStore.RemoveAllDeactivatedMembers(channelID)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.RemoveAllDeactivatedMembers", success, elapsed)
|
|
}
|
|
return err
|
|
}
|
|
|
|
func (s *TimerLayerChannelStore) RemoveMember(channelID string, userId string) error {
|
|
start := timemodule.Now()
|
|
|
|
err := s.ChannelStore.RemoveMember(channelID, userId)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.RemoveMember", success, elapsed)
|
|
}
|
|
return err
|
|
}
|
|
|
|
func (s *TimerLayerChannelStore) RemoveMembers(channelID string, userIds []string) error {
|
|
start := timemodule.Now()
|
|
|
|
err := s.ChannelStore.RemoveMembers(channelID, userIds)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.RemoveMembers", success, elapsed)
|
|
}
|
|
return err
|
|
}
|
|
|
|
func (s *TimerLayerChannelStore) ResetAllChannelSchemes() error {
|
|
start := timemodule.Now()
|
|
|
|
err := s.ChannelStore.ResetAllChannelSchemes()
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.ResetAllChannelSchemes", success, elapsed)
|
|
}
|
|
return err
|
|
}
|
|
|
|
func (s *TimerLayerChannelStore) Restore(channelID string, time int64) error {
|
|
start := timemodule.Now()
|
|
|
|
err := s.ChannelStore.Restore(channelID, time)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.Restore", success, elapsed)
|
|
}
|
|
return err
|
|
}
|
|
|
|
func (s *TimerLayerChannelStore) Save(channel *model.Channel, maxChannelsPerTeam int64) (*model.Channel, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.ChannelStore.Save(channel, maxChannelsPerTeam)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.Save", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerChannelStore) SaveDirectChannel(channel *model.Channel, member1 *model.ChannelMember, member2 *model.ChannelMember) (*model.Channel, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.ChannelStore.SaveDirectChannel(channel, member1, member2)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.SaveDirectChannel", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerChannelStore) SaveMember(member *model.ChannelMember) (*model.ChannelMember, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.ChannelStore.SaveMember(member)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.SaveMember", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerChannelStore) SaveMultipleMembers(members []*model.ChannelMember) ([]*model.ChannelMember, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.ChannelStore.SaveMultipleMembers(members)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.SaveMultipleMembers", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerChannelStore) SearchAllChannels(term string, opts store.ChannelSearchOpts) (*model.ChannelListWithTeamData, int64, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, resultVar1, err := s.ChannelStore.SearchAllChannels(term, opts)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.SearchAllChannels", success, elapsed)
|
|
}
|
|
return result, resultVar1, err
|
|
}
|
|
|
|
func (s *TimerLayerChannelStore) SearchArchivedInTeam(teamID string, term string, userId string) (*model.ChannelList, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.ChannelStore.SearchArchivedInTeam(teamID, term, userId)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.SearchArchivedInTeam", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerChannelStore) SearchForUserInTeam(userId string, teamID string, term string, includeDeleted bool) (*model.ChannelList, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.ChannelStore.SearchForUserInTeam(userId, teamID, term, 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("ChannelStore.SearchForUserInTeam", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerChannelStore) SearchGroupChannels(userId string, term string) (*model.ChannelList, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.ChannelStore.SearchGroupChannels(userId, term)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.SearchGroupChannels", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerChannelStore) SearchInTeam(teamID string, term string, includeDeleted bool) (*model.ChannelList, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.ChannelStore.SearchInTeam(teamID, term, 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("ChannelStore.SearchInTeam", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerChannelStore) SearchMore(userId string, teamID string, term string) (*model.ChannelList, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.ChannelStore.SearchMore(userId, teamID, term)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.SearchMore", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerChannelStore) SetDeleteAt(channelID string, deleteAt int64, updateAt int64) error {
|
|
start := timemodule.Now()
|
|
|
|
err := s.ChannelStore.SetDeleteAt(channelID, deleteAt, updateAt)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.SetDeleteAt", success, elapsed)
|
|
}
|
|
return err
|
|
}
|
|
|
|
func (s *TimerLayerChannelStore) Update(channel *model.Channel) (*model.Channel, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.ChannelStore.Update(channel)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.Update", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerChannelStore) UpdateLastViewedAt(channelIds []string, userId string, updateThreads bool) (map[string]int64, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.ChannelStore.UpdateLastViewedAt(channelIds, userId, updateThreads)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.UpdateLastViewedAt", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerChannelStore) UpdateLastViewedAtPost(unreadPost *model.Post, userID string, mentionCount int, updateThreads bool) (*model.ChannelUnreadAt, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.ChannelStore.UpdateLastViewedAtPost(unreadPost, userID, mentionCount, updateThreads)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.UpdateLastViewedAtPost", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerChannelStore) UpdateMember(member *model.ChannelMember) (*model.ChannelMember, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.ChannelStore.UpdateMember(member)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.UpdateMember", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerChannelStore) UpdateMembersRole(channelID string, userIDs []string) error {
|
|
start := timemodule.Now()
|
|
|
|
err := s.ChannelStore.UpdateMembersRole(channelID, userIDs)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.UpdateMembersRole", success, elapsed)
|
|
}
|
|
return err
|
|
}
|
|
|
|
func (s *TimerLayerChannelStore) UpdateMultipleMembers(members []*model.ChannelMember) ([]*model.ChannelMember, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.ChannelStore.UpdateMultipleMembers(members)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.UpdateMultipleMembers", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerChannelStore) UpdateSidebarCategories(userId string, teamID string, categories []*model.SidebarCategoryWithChannels) ([]*model.SidebarCategoryWithChannels, []*model.SidebarCategoryWithChannels, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, resultVar1, err := s.ChannelStore.UpdateSidebarCategories(userId, teamID, categories)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.UpdateSidebarCategories", success, elapsed)
|
|
}
|
|
return result, resultVar1, err
|
|
}
|
|
|
|
func (s *TimerLayerChannelStore) UpdateSidebarCategoryOrder(userId string, teamID string, categoryOrder []string) error {
|
|
start := timemodule.Now()
|
|
|
|
err := s.ChannelStore.UpdateSidebarCategoryOrder(userId, teamID, categoryOrder)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.UpdateSidebarCategoryOrder", success, elapsed)
|
|
}
|
|
return err
|
|
}
|
|
|
|
func (s *TimerLayerChannelStore) UpdateSidebarChannelCategoryOnMove(channel *model.Channel, newTeamID string) error {
|
|
start := timemodule.Now()
|
|
|
|
err := s.ChannelStore.UpdateSidebarChannelCategoryOnMove(channel, newTeamID)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.UpdateSidebarChannelCategoryOnMove", success, elapsed)
|
|
}
|
|
return err
|
|
}
|
|
|
|
func (s *TimerLayerChannelStore) UpdateSidebarChannelsByPreferences(preferences *model.Preferences) error {
|
|
start := timemodule.Now()
|
|
|
|
err := s.ChannelStore.UpdateSidebarChannelsByPreferences(preferences)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.UpdateSidebarChannelsByPreferences", success, elapsed)
|
|
}
|
|
return err
|
|
}
|
|
|
|
func (s *TimerLayerChannelStore) UserBelongsToChannels(userId string, channelIds []string) (bool, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.ChannelStore.UserBelongsToChannels(userId, channelIds)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.UserBelongsToChannels", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerChannelMemberHistoryStore) GetUsersInChannelDuring(startTime int64, endTime int64, channelID string) ([]*model.ChannelMemberHistoryResult, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.ChannelMemberHistoryStore.GetUsersInChannelDuring(startTime, endTime, channelID)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("ChannelMemberHistoryStore.GetUsersInChannelDuring", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerChannelMemberHistoryStore) LogJoinEvent(userId string, channelID string, joinTime int64) error {
|
|
start := timemodule.Now()
|
|
|
|
err := s.ChannelMemberHistoryStore.LogJoinEvent(userId, channelID, joinTime)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("ChannelMemberHistoryStore.LogJoinEvent", success, elapsed)
|
|
}
|
|
return err
|
|
}
|
|
|
|
func (s *TimerLayerChannelMemberHistoryStore) LogLeaveEvent(userId string, channelID string, leaveTime int64) error {
|
|
start := timemodule.Now()
|
|
|
|
err := s.ChannelMemberHistoryStore.LogLeaveEvent(userId, channelID, leaveTime)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("ChannelMemberHistoryStore.LogLeaveEvent", success, elapsed)
|
|
}
|
|
return err
|
|
}
|
|
|
|
func (s *TimerLayerChannelMemberHistoryStore) PermanentDeleteBatch(endTime int64, limit int64) (int64, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.ChannelMemberHistoryStore.PermanentDeleteBatch(endTime, limit)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("ChannelMemberHistoryStore.PermanentDeleteBatch", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerClusterDiscoveryStore) Cleanup() error {
|
|
start := timemodule.Now()
|
|
|
|
err := s.ClusterDiscoveryStore.Cleanup()
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("ClusterDiscoveryStore.Cleanup", success, elapsed)
|
|
}
|
|
return err
|
|
}
|
|
|
|
func (s *TimerLayerClusterDiscoveryStore) Delete(discovery *model.ClusterDiscovery) (bool, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.ClusterDiscoveryStore.Delete(discovery)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("ClusterDiscoveryStore.Delete", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerClusterDiscoveryStore) Exists(discovery *model.ClusterDiscovery) (bool, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.ClusterDiscoveryStore.Exists(discovery)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("ClusterDiscoveryStore.Exists", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerClusterDiscoveryStore) GetAll(discoveryType string, clusterName string) ([]*model.ClusterDiscovery, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.ClusterDiscoveryStore.GetAll(discoveryType, clusterName)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("ClusterDiscoveryStore.GetAll", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerClusterDiscoveryStore) Save(discovery *model.ClusterDiscovery) error {
|
|
start := timemodule.Now()
|
|
|
|
err := s.ClusterDiscoveryStore.Save(discovery)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("ClusterDiscoveryStore.Save", success, elapsed)
|
|
}
|
|
return err
|
|
}
|
|
|
|
func (s *TimerLayerClusterDiscoveryStore) SetLastPingAt(discovery *model.ClusterDiscovery) error {
|
|
start := timemodule.Now()
|
|
|
|
err := s.ClusterDiscoveryStore.SetLastPingAt(discovery)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("ClusterDiscoveryStore.SetLastPingAt", success, elapsed)
|
|
}
|
|
return err
|
|
}
|
|
|
|
func (s *TimerLayerCommandStore) AnalyticsCommandCount(teamID string) (int64, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.CommandStore.AnalyticsCommandCount(teamID)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("CommandStore.AnalyticsCommandCount", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerCommandStore) Delete(commandID string, time int64) error {
|
|
start := timemodule.Now()
|
|
|
|
err := s.CommandStore.Delete(commandID, time)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("CommandStore.Delete", success, elapsed)
|
|
}
|
|
return err
|
|
}
|
|
|
|
func (s *TimerLayerCommandStore) Get(id string) (*model.Command, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.CommandStore.Get(id)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("CommandStore.Get", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerCommandStore) GetByTeam(teamID string) ([]*model.Command, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.CommandStore.GetByTeam(teamID)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("CommandStore.GetByTeam", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerCommandStore) GetByTrigger(teamID string, trigger string) (*model.Command, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.CommandStore.GetByTrigger(teamID, trigger)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("CommandStore.GetByTrigger", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerCommandStore) PermanentDeleteByTeam(teamID string) error {
|
|
start := timemodule.Now()
|
|
|
|
err := s.CommandStore.PermanentDeleteByTeam(teamID)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("CommandStore.PermanentDeleteByTeam", success, elapsed)
|
|
}
|
|
return err
|
|
}
|
|
|
|
func (s *TimerLayerCommandStore) PermanentDeleteByUser(userId string) error {
|
|
start := timemodule.Now()
|
|
|
|
err := s.CommandStore.PermanentDeleteByUser(userId)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("CommandStore.PermanentDeleteByUser", success, elapsed)
|
|
}
|
|
return err
|
|
}
|
|
|
|
func (s *TimerLayerCommandStore) Save(webhook *model.Command) (*model.Command, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.CommandStore.Save(webhook)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("CommandStore.Save", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerCommandStore) Update(hook *model.Command) (*model.Command, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.CommandStore.Update(hook)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("CommandStore.Update", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerCommandWebhookStore) Cleanup() {
|
|
start := timemodule.Now()
|
|
|
|
s.CommandWebhookStore.Cleanup()
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if true {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("CommandWebhookStore.Cleanup", success, elapsed)
|
|
}
|
|
}
|
|
|
|
func (s *TimerLayerCommandWebhookStore) Get(id string) (*model.CommandWebhook, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.CommandWebhookStore.Get(id)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("CommandWebhookStore.Get", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerCommandWebhookStore) Save(webhook *model.CommandWebhook) (*model.CommandWebhook, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.CommandWebhookStore.Save(webhook)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("CommandWebhookStore.Save", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerCommandWebhookStore) TryUse(id string, limit int) error {
|
|
start := timemodule.Now()
|
|
|
|
err := s.CommandWebhookStore.TryUse(id, limit)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("CommandWebhookStore.TryUse", success, elapsed)
|
|
}
|
|
return err
|
|
}
|
|
|
|
func (s *TimerLayerComplianceStore) ComplianceExport(compliance *model.Compliance) ([]*model.CompliancePost, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.ComplianceStore.ComplianceExport(compliance)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("ComplianceStore.ComplianceExport", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerComplianceStore) Get(id string) (*model.Compliance, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.ComplianceStore.Get(id)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("ComplianceStore.Get", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerComplianceStore) GetAll(offset int, limit int) (model.Compliances, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.ComplianceStore.GetAll(offset, limit)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("ComplianceStore.GetAll", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerComplianceStore) MessageExport(after int64, limit int) ([]*model.MessageExport, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.ComplianceStore.MessageExport(after, limit)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("ComplianceStore.MessageExport", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerComplianceStore) Save(compliance *model.Compliance) (*model.Compliance, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.ComplianceStore.Save(compliance)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("ComplianceStore.Save", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerComplianceStore) Update(compliance *model.Compliance) (*model.Compliance, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.ComplianceStore.Update(compliance)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("ComplianceStore.Update", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerEmojiStore) Delete(emoji *model.Emoji, time int64) error {
|
|
start := timemodule.Now()
|
|
|
|
err := s.EmojiStore.Delete(emoji, time)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("EmojiStore.Delete", success, elapsed)
|
|
}
|
|
return err
|
|
}
|
|
|
|
func (s *TimerLayerEmojiStore) Get(ctx context.Context, id string, allowFromCache bool) (*model.Emoji, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.EmojiStore.Get(ctx, id, allowFromCache)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("EmojiStore.Get", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerEmojiStore) GetByName(ctx context.Context, name string, allowFromCache bool) (*model.Emoji, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.EmojiStore.GetByName(ctx, name, allowFromCache)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("EmojiStore.GetByName", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerEmojiStore) GetList(offset int, limit int, sort string) ([]*model.Emoji, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.EmojiStore.GetList(offset, limit, sort)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("EmojiStore.GetList", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerEmojiStore) GetMultipleByName(names []string) ([]*model.Emoji, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.EmojiStore.GetMultipleByName(names)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("EmojiStore.GetMultipleByName", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerEmojiStore) Save(emoji *model.Emoji) (*model.Emoji, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.EmojiStore.Save(emoji)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("EmojiStore.Save", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerEmojiStore) Search(name string, prefixOnly bool, limit int) ([]*model.Emoji, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.EmojiStore.Search(name, prefixOnly, limit)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("EmojiStore.Search", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerFileInfoStore) AttachToPost(fileID string, postID string, creatorId string) error {
|
|
start := timemodule.Now()
|
|
|
|
err := s.FileInfoStore.AttachToPost(fileID, postID, creatorId)
|
|
|
|
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.AttachToPost", success, elapsed)
|
|
}
|
|
return err
|
|
}
|
|
|
|
func (s *TimerLayerFileInfoStore) ClearCaches() {
|
|
start := timemodule.Now()
|
|
|
|
s.FileInfoStore.ClearCaches()
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if true {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("FileInfoStore.ClearCaches", success, elapsed)
|
|
}
|
|
}
|
|
|
|
func (s *TimerLayerFileInfoStore) CountAll() (int64, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.FileInfoStore.CountAll()
|
|
|
|
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.CountAll", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerFileInfoStore) DeleteForPost(postID string) (string, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.FileInfoStore.DeleteForPost(postID)
|
|
|
|
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.DeleteForPost", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerFileInfoStore) Get(id string) (*model.FileInfo, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.FileInfoStore.Get(id)
|
|
|
|
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.Get", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerFileInfoStore) GetByIds(ids []string) ([]*model.FileInfo, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.FileInfoStore.GetByIds(ids)
|
|
|
|
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.GetByIds", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerFileInfoStore) GetByPath(path string) (*model.FileInfo, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.FileInfoStore.GetByPath(path)
|
|
|
|
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.GetByPath", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerFileInfoStore) GetFilesBatchForIndexing(startTime int64, endTime int64, limit int) ([]*model.FileForIndexing, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.FileInfoStore.GetFilesBatchForIndexing(startTime, endTime, limit)
|
|
|
|
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.GetFilesBatchForIndexing", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerFileInfoStore) GetForPost(postID string, readFromMaster bool, includeDeleted bool, allowFromCache bool) ([]*model.FileInfo, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.FileInfoStore.GetForPost(postID, readFromMaster, includeDeleted, allowFromCache)
|
|
|
|
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.GetForPost", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerFileInfoStore) GetForUser(userId string) ([]*model.FileInfo, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.FileInfoStore.GetForUser(userId)
|
|
|
|
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.GetForUser", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerFileInfoStore) GetWithOptions(page int, perPage int, opt *model.GetFileInfosOptions) ([]*model.FileInfo, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.FileInfoStore.GetWithOptions(page, perPage, opt)
|
|
|
|
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.GetWithOptions", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerFileInfoStore) InvalidateFileInfosForPostCache(postID string, deleted bool) {
|
|
start := timemodule.Now()
|
|
|
|
s.FileInfoStore.InvalidateFileInfosForPostCache(postID, deleted)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if true {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("FileInfoStore.InvalidateFileInfosForPostCache", success, elapsed)
|
|
}
|
|
}
|
|
|
|
func (s *TimerLayerFileInfoStore) PermanentDelete(fileID string) error {
|
|
start := timemodule.Now()
|
|
|
|
err := s.FileInfoStore.PermanentDelete(fileID)
|
|
|
|
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.PermanentDelete", success, elapsed)
|
|
}
|
|
return err
|
|
}
|
|
|
|
func (s *TimerLayerFileInfoStore) PermanentDeleteBatch(endTime int64, limit int64) (int64, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.FileInfoStore.PermanentDeleteBatch(endTime, limit)
|
|
|
|
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.PermanentDeleteBatch", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerFileInfoStore) PermanentDeleteByUser(userId string) (int64, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.FileInfoStore.PermanentDeleteByUser(userId)
|
|
|
|
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.PermanentDeleteByUser", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerFileInfoStore) Save(info *model.FileInfo) (*model.FileInfo, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.FileInfoStore.Save(info)
|
|
|
|
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.Save", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerFileInfoStore) Search(paramsList []*model.SearchParams, userId string, teamID string, page int, perPage int) (*model.FileInfoList, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.FileInfoStore.Search(paramsList, userId, teamID, page, perPage)
|
|
|
|
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.Search", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerFileInfoStore) SetContent(fileID string, content string) error {
|
|
start := timemodule.Now()
|
|
|
|
err := s.FileInfoStore.SetContent(fileID, content)
|
|
|
|
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.SetContent", success, elapsed)
|
|
}
|
|
return err
|
|
}
|
|
|
|
func (s *TimerLayerFileInfoStore) Upsert(info *model.FileInfo) (*model.FileInfo, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.FileInfoStore.Upsert(info)
|
|
|
|
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.Upsert", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerGroupStore) AdminRoleGroupsForSyncableMember(userID string, syncableID string, syncableType model.GroupSyncableType) ([]string, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.GroupStore.AdminRoleGroupsForSyncableMember(userID, syncableID, syncableType)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("GroupStore.AdminRoleGroupsForSyncableMember", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerGroupStore) ChannelMembersMinusGroupMembers(channelID string, groupIDs []string, page int, perPage int) ([]*model.UserWithGroups, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.GroupStore.ChannelMembersMinusGroupMembers(channelID, groupIDs, page, perPage)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("GroupStore.ChannelMembersMinusGroupMembers", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerGroupStore) ChannelMembersToAdd(since int64, channelID *string) ([]*model.UserChannelIDPair, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.GroupStore.ChannelMembersToAdd(since, channelID)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("GroupStore.ChannelMembersToAdd", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerGroupStore) ChannelMembersToRemove(channelID *string) ([]*model.ChannelMember, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.GroupStore.ChannelMembersToRemove(channelID)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("GroupStore.ChannelMembersToRemove", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerGroupStore) CountChannelMembersMinusGroupMembers(channelID string, groupIDs []string) (int64, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.GroupStore.CountChannelMembersMinusGroupMembers(channelID, groupIDs)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("GroupStore.CountChannelMembersMinusGroupMembers", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerGroupStore) CountGroupsByChannel(channelID string, opts model.GroupSearchOpts) (int64, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.GroupStore.CountGroupsByChannel(channelID, opts)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("GroupStore.CountGroupsByChannel", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerGroupStore) CountGroupsByTeam(teamID string, opts model.GroupSearchOpts) (int64, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.GroupStore.CountGroupsByTeam(teamID, opts)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("GroupStore.CountGroupsByTeam", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerGroupStore) CountTeamMembersMinusGroupMembers(teamID string, groupIDs []string) (int64, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.GroupStore.CountTeamMembersMinusGroupMembers(teamID, groupIDs)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("GroupStore.CountTeamMembersMinusGroupMembers", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerGroupStore) Create(group *model.Group) (*model.Group, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.GroupStore.Create(group)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("GroupStore.Create", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerGroupStore) CreateGroupSyncable(groupSyncable *model.GroupSyncable) (*model.GroupSyncable, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.GroupStore.CreateGroupSyncable(groupSyncable)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("GroupStore.CreateGroupSyncable", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerGroupStore) Delete(groupID string) (*model.Group, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.GroupStore.Delete(groupID)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("GroupStore.Delete", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerGroupStore) DeleteGroupSyncable(groupID string, syncableID string, syncableType model.GroupSyncableType) (*model.GroupSyncable, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.GroupStore.DeleteGroupSyncable(groupID, syncableID, syncableType)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("GroupStore.DeleteGroupSyncable", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerGroupStore) DeleteMember(groupID string, userID string) (*model.GroupMember, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.GroupStore.DeleteMember(groupID, userID)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("GroupStore.DeleteMember", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerGroupStore) DistinctGroupMemberCount() (int64, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.GroupStore.DistinctGroupMemberCount()
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("GroupStore.DistinctGroupMemberCount", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerGroupStore) Get(groupID string) (*model.Group, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.GroupStore.Get(groupID)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("GroupStore.Get", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerGroupStore) GetAllBySource(groupSource model.GroupSource) ([]*model.Group, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.GroupStore.GetAllBySource(groupSource)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("GroupStore.GetAllBySource", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerGroupStore) GetAllGroupSyncablesByGroupId(groupID string, syncableType model.GroupSyncableType) ([]*model.GroupSyncable, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.GroupStore.GetAllGroupSyncablesByGroupId(groupID, syncableType)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("GroupStore.GetAllGroupSyncablesByGroupId", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerGroupStore) GetByIDs(groupIDs []string) ([]*model.Group, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.GroupStore.GetByIDs(groupIDs)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("GroupStore.GetByIDs", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerGroupStore) GetByName(name string, opts model.GroupSearchOpts) (*model.Group, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.GroupStore.GetByName(name, opts)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("GroupStore.GetByName", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerGroupStore) GetByRemoteID(remoteID string, groupSource model.GroupSource) (*model.Group, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.GroupStore.GetByRemoteID(remoteID, groupSource)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("GroupStore.GetByRemoteID", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerGroupStore) GetByUser(userId string) ([]*model.Group, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.GroupStore.GetByUser(userId)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("GroupStore.GetByUser", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerGroupStore) GetGroupSyncable(groupID string, syncableID string, syncableType model.GroupSyncableType) (*model.GroupSyncable, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.GroupStore.GetGroupSyncable(groupID, syncableID, syncableType)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("GroupStore.GetGroupSyncable", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerGroupStore) GetGroups(page int, perPage int, opts model.GroupSearchOpts) ([]*model.Group, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.GroupStore.GetGroups(page, perPage, opts)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("GroupStore.GetGroups", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerGroupStore) GetGroupsAssociatedToChannelsByTeam(teamID string, opts model.GroupSearchOpts) (map[string][]*model.GroupWithSchemeAdmin, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.GroupStore.GetGroupsAssociatedToChannelsByTeam(teamID, opts)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("GroupStore.GetGroupsAssociatedToChannelsByTeam", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerGroupStore) GetGroupsByChannel(channelID string, opts model.GroupSearchOpts) ([]*model.GroupWithSchemeAdmin, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.GroupStore.GetGroupsByChannel(channelID, opts)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("GroupStore.GetGroupsByChannel", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerGroupStore) GetGroupsByTeam(teamID string, opts model.GroupSearchOpts) ([]*model.GroupWithSchemeAdmin, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.GroupStore.GetGroupsByTeam(teamID, opts)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("GroupStore.GetGroupsByTeam", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerGroupStore) GetMemberCount(groupID string) (int64, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.GroupStore.GetMemberCount(groupID)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("GroupStore.GetMemberCount", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerGroupStore) GetMemberUsers(groupID string) ([]*model.User, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.GroupStore.GetMemberUsers(groupID)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("GroupStore.GetMemberUsers", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerGroupStore) GetMemberUsersInTeam(groupID string, teamID string) ([]*model.User, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.GroupStore.GetMemberUsersInTeam(groupID, teamID)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("GroupStore.GetMemberUsersInTeam", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerGroupStore) GetMemberUsersNotInChannel(groupID string, channelID string) ([]*model.User, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.GroupStore.GetMemberUsersNotInChannel(groupID, channelID)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("GroupStore.GetMemberUsersNotInChannel", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerGroupStore) GetMemberUsersPage(groupID string, page int, perPage int) ([]*model.User, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.GroupStore.GetMemberUsersPage(groupID, page, perPage)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("GroupStore.GetMemberUsersPage", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerGroupStore) GroupChannelCount() (int64, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.GroupStore.GroupChannelCount()
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("GroupStore.GroupChannelCount", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerGroupStore) GroupCount() (int64, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.GroupStore.GroupCount()
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("GroupStore.GroupCount", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerGroupStore) GroupCountWithAllowReference() (int64, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.GroupStore.GroupCountWithAllowReference()
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("GroupStore.GroupCountWithAllowReference", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerGroupStore) GroupMemberCount() (int64, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.GroupStore.GroupMemberCount()
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("GroupStore.GroupMemberCount", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerGroupStore) GroupTeamCount() (int64, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.GroupStore.GroupTeamCount()
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("GroupStore.GroupTeamCount", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerGroupStore) PermanentDeleteMembersByUser(userId string) error {
|
|
start := timemodule.Now()
|
|
|
|
err := s.GroupStore.PermanentDeleteMembersByUser(userId)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("GroupStore.PermanentDeleteMembersByUser", success, elapsed)
|
|
}
|
|
return err
|
|
}
|
|
|
|
func (s *TimerLayerGroupStore) PermittedSyncableAdmins(syncableID string, syncableType model.GroupSyncableType) ([]string, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.GroupStore.PermittedSyncableAdmins(syncableID, syncableType)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("GroupStore.PermittedSyncableAdmins", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerGroupStore) TeamMembersMinusGroupMembers(teamID string, groupIDs []string, page int, perPage int) ([]*model.UserWithGroups, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.GroupStore.TeamMembersMinusGroupMembers(teamID, groupIDs, page, perPage)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("GroupStore.TeamMembersMinusGroupMembers", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerGroupStore) TeamMembersToAdd(since int64, teamID *string) ([]*model.UserTeamIDPair, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.GroupStore.TeamMembersToAdd(since, teamID)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("GroupStore.TeamMembersToAdd", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerGroupStore) TeamMembersToRemove(teamID *string) ([]*model.TeamMember, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.GroupStore.TeamMembersToRemove(teamID)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("GroupStore.TeamMembersToRemove", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerGroupStore) Update(group *model.Group) (*model.Group, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.GroupStore.Update(group)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("GroupStore.Update", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerGroupStore) UpdateGroupSyncable(groupSyncable *model.GroupSyncable) (*model.GroupSyncable, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.GroupStore.UpdateGroupSyncable(groupSyncable)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("GroupStore.UpdateGroupSyncable", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerGroupStore) UpsertMember(groupID string, userID string) (*model.GroupMember, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.GroupStore.UpsertMember(groupID, userID)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("GroupStore.UpsertMember", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerJobStore) Delete(id string) (string, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.JobStore.Delete(id)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("JobStore.Delete", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerJobStore) Get(id string) (*model.Job, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.JobStore.Get(id)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("JobStore.Get", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerJobStore) GetAllByStatus(status string) ([]*model.Job, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.JobStore.GetAllByStatus(status)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("JobStore.GetAllByStatus", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerJobStore) GetAllByType(jobType string) ([]*model.Job, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.JobStore.GetAllByType(jobType)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("JobStore.GetAllByType", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerJobStore) GetAllByTypePage(jobType string, offset int, limit int) ([]*model.Job, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.JobStore.GetAllByTypePage(jobType, offset, limit)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("JobStore.GetAllByTypePage", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerJobStore) GetAllPage(offset int, limit int) ([]*model.Job, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.JobStore.GetAllPage(offset, limit)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("JobStore.GetAllPage", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerJobStore) GetCountByStatusAndType(status string, jobType string) (int64, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.JobStore.GetCountByStatusAndType(status, jobType)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("JobStore.GetCountByStatusAndType", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerJobStore) GetNewestJobByStatusAndType(status string, jobType string) (*model.Job, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.JobStore.GetNewestJobByStatusAndType(status, jobType)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("JobStore.GetNewestJobByStatusAndType", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerJobStore) GetNewestJobByStatusesAndType(statuses []string, jobType string) (*model.Job, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.JobStore.GetNewestJobByStatusesAndType(statuses, jobType)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("JobStore.GetNewestJobByStatusesAndType", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerJobStore) Save(job *model.Job) (*model.Job, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.JobStore.Save(job)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("JobStore.Save", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerJobStore) UpdateOptimistically(job *model.Job, currentStatus string) (bool, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.JobStore.UpdateOptimistically(job, currentStatus)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("JobStore.UpdateOptimistically", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerJobStore) UpdateStatus(id string, status string) (*model.Job, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.JobStore.UpdateStatus(id, status)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("JobStore.UpdateStatus", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerJobStore) UpdateStatusOptimistically(id string, currentStatus string, newStatus string) (bool, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.JobStore.UpdateStatusOptimistically(id, currentStatus, newStatus)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("JobStore.UpdateStatusOptimistically", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerLicenseStore) Get(id string) (*model.LicenseRecord, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.LicenseStore.Get(id)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("LicenseStore.Get", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerLicenseStore) Save(license *model.LicenseRecord) (*model.LicenseRecord, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.LicenseStore.Save(license)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("LicenseStore.Save", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerLinkMetadataStore) Get(url string, timestamp int64) (*model.LinkMetadata, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.LinkMetadataStore.Get(url, timestamp)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("LinkMetadataStore.Get", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerLinkMetadataStore) Save(linkMetadata *model.LinkMetadata) (*model.LinkMetadata, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.LinkMetadataStore.Save(linkMetadata)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("LinkMetadataStore.Save", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerOAuthStore) DeleteApp(id string) error {
|
|
start := timemodule.Now()
|
|
|
|
err := s.OAuthStore.DeleteApp(id)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("OAuthStore.DeleteApp", success, elapsed)
|
|
}
|
|
return err
|
|
}
|
|
|
|
func (s *TimerLayerOAuthStore) GetAccessData(token string) (*model.AccessData, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.OAuthStore.GetAccessData(token)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("OAuthStore.GetAccessData", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerOAuthStore) GetAccessDataByRefreshToken(token string) (*model.AccessData, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.OAuthStore.GetAccessDataByRefreshToken(token)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("OAuthStore.GetAccessDataByRefreshToken", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerOAuthStore) GetAccessDataByUserForApp(userId string, clientId string) ([]*model.AccessData, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.OAuthStore.GetAccessDataByUserForApp(userId, clientId)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("OAuthStore.GetAccessDataByUserForApp", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerOAuthStore) GetApp(id string) (*model.OAuthApp, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.OAuthStore.GetApp(id)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("OAuthStore.GetApp", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerOAuthStore) GetAppByUser(userId string, offset int, limit int) ([]*model.OAuthApp, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.OAuthStore.GetAppByUser(userId, offset, limit)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("OAuthStore.GetAppByUser", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerOAuthStore) GetApps(offset int, limit int) ([]*model.OAuthApp, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.OAuthStore.GetApps(offset, limit)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("OAuthStore.GetApps", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerOAuthStore) GetAuthData(code string) (*model.AuthData, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.OAuthStore.GetAuthData(code)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("OAuthStore.GetAuthData", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerOAuthStore) GetAuthorizedApps(userId string, offset int, limit int) ([]*model.OAuthApp, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.OAuthStore.GetAuthorizedApps(userId, offset, limit)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("OAuthStore.GetAuthorizedApps", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerOAuthStore) GetPreviousAccessData(userId string, clientId string) (*model.AccessData, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.OAuthStore.GetPreviousAccessData(userId, clientId)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("OAuthStore.GetPreviousAccessData", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerOAuthStore) PermanentDeleteAuthDataByUser(userId string) error {
|
|
start := timemodule.Now()
|
|
|
|
err := s.OAuthStore.PermanentDeleteAuthDataByUser(userId)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("OAuthStore.PermanentDeleteAuthDataByUser", success, elapsed)
|
|
}
|
|
return err
|
|
}
|
|
|
|
func (s *TimerLayerOAuthStore) RemoveAccessData(token string) error {
|
|
start := timemodule.Now()
|
|
|
|
err := s.OAuthStore.RemoveAccessData(token)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("OAuthStore.RemoveAccessData", success, elapsed)
|
|
}
|
|
return err
|
|
}
|
|
|
|
func (s *TimerLayerOAuthStore) RemoveAllAccessData() error {
|
|
start := timemodule.Now()
|
|
|
|
err := s.OAuthStore.RemoveAllAccessData()
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("OAuthStore.RemoveAllAccessData", success, elapsed)
|
|
}
|
|
return err
|
|
}
|
|
|
|
func (s *TimerLayerOAuthStore) RemoveAuthData(code string) error {
|
|
start := timemodule.Now()
|
|
|
|
err := s.OAuthStore.RemoveAuthData(code)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("OAuthStore.RemoveAuthData", success, elapsed)
|
|
}
|
|
return err
|
|
}
|
|
|
|
func (s *TimerLayerOAuthStore) SaveAccessData(accessData *model.AccessData) (*model.AccessData, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.OAuthStore.SaveAccessData(accessData)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("OAuthStore.SaveAccessData", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerOAuthStore) SaveApp(app *model.OAuthApp) (*model.OAuthApp, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.OAuthStore.SaveApp(app)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("OAuthStore.SaveApp", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerOAuthStore) SaveAuthData(authData *model.AuthData) (*model.AuthData, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.OAuthStore.SaveAuthData(authData)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("OAuthStore.SaveAuthData", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerOAuthStore) UpdateAccessData(accessData *model.AccessData) (*model.AccessData, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.OAuthStore.UpdateAccessData(accessData)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("OAuthStore.UpdateAccessData", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerOAuthStore) UpdateApp(app *model.OAuthApp) (*model.OAuthApp, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.OAuthStore.UpdateApp(app)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("OAuthStore.UpdateApp", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerPluginStore) CompareAndDelete(keyVal *model.PluginKeyValue, oldValue []byte) (bool, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.PluginStore.CompareAndDelete(keyVal, oldValue)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("PluginStore.CompareAndDelete", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerPluginStore) CompareAndSet(keyVal *model.PluginKeyValue, oldValue []byte) (bool, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.PluginStore.CompareAndSet(keyVal, oldValue)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("PluginStore.CompareAndSet", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerPluginStore) Delete(pluginID string, key string) error {
|
|
start := timemodule.Now()
|
|
|
|
err := s.PluginStore.Delete(pluginID, key)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("PluginStore.Delete", success, elapsed)
|
|
}
|
|
return err
|
|
}
|
|
|
|
func (s *TimerLayerPluginStore) DeleteAllExpired() error {
|
|
start := timemodule.Now()
|
|
|
|
err := s.PluginStore.DeleteAllExpired()
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("PluginStore.DeleteAllExpired", success, elapsed)
|
|
}
|
|
return err
|
|
}
|
|
|
|
func (s *TimerLayerPluginStore) DeleteAllForPlugin(PluginID string) error {
|
|
start := timemodule.Now()
|
|
|
|
err := s.PluginStore.DeleteAllForPlugin(PluginID)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("PluginStore.DeleteAllForPlugin", success, elapsed)
|
|
}
|
|
return err
|
|
}
|
|
|
|
func (s *TimerLayerPluginStore) Get(pluginID string, key string) (*model.PluginKeyValue, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.PluginStore.Get(pluginID, key)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("PluginStore.Get", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerPluginStore) List(pluginID string, page int, perPage int) ([]string, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.PluginStore.List(pluginID, page, perPage)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("PluginStore.List", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerPluginStore) SaveOrUpdate(keyVal *model.PluginKeyValue) (*model.PluginKeyValue, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.PluginStore.SaveOrUpdate(keyVal)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("PluginStore.SaveOrUpdate", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerPluginStore) SetWithOptions(pluginID string, key string, value []byte, options model.PluginKVSetOptions) (bool, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.PluginStore.SetWithOptions(pluginID, key, value, options)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("PluginStore.SetWithOptions", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerPostStore) AnalyticsPostCount(teamID string, mustHaveFile bool, mustHaveHashtag bool) (int64, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.PostStore.AnalyticsPostCount(teamID, mustHaveFile, mustHaveHashtag)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("PostStore.AnalyticsPostCount", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerPostStore) AnalyticsPostCountsByDay(options *model.AnalyticsPostCountsOptions) (model.AnalyticsRows, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.PostStore.AnalyticsPostCountsByDay(options)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("PostStore.AnalyticsPostCountsByDay", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerPostStore) AnalyticsUserCountsWithPostsByDay(teamID string) (model.AnalyticsRows, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.PostStore.AnalyticsUserCountsWithPostsByDay(teamID)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("PostStore.AnalyticsUserCountsWithPostsByDay", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerPostStore) ClearCaches() {
|
|
start := timemodule.Now()
|
|
|
|
s.PostStore.ClearCaches()
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if true {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("PostStore.ClearCaches", success, elapsed)
|
|
}
|
|
}
|
|
|
|
func (s *TimerLayerPostStore) Delete(postID string, time int64, deleteByID string) error {
|
|
start := timemodule.Now()
|
|
|
|
err := s.PostStore.Delete(postID, time, deleteByID)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("PostStore.Delete", success, elapsed)
|
|
}
|
|
return err
|
|
}
|
|
|
|
func (s *TimerLayerPostStore) Get(ctx context.Context, id string, skipFetchThreads bool, collapsedThreads bool, collapsedThreadsExtended bool) (*model.PostList, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.PostStore.Get(ctx, id, skipFetchThreads, collapsedThreads, collapsedThreadsExtended)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("PostStore.Get", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerPostStore) GetDirectPostParentsForExportAfter(limit int, afterID string) ([]*model.DirectPostForExport, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.PostStore.GetDirectPostParentsForExportAfter(limit, afterID)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("PostStore.GetDirectPostParentsForExportAfter", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerPostStore) GetEtag(channelID string, allowFromCache bool, collapsedThreads bool) string {
|
|
start := timemodule.Now()
|
|
|
|
result := s.PostStore.GetEtag(channelID, allowFromCache, collapsedThreads)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if true {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("PostStore.GetEtag", success, elapsed)
|
|
}
|
|
return result
|
|
}
|
|
|
|
func (s *TimerLayerPostStore) GetFlaggedPosts(userId string, offset int, limit int) (*model.PostList, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.PostStore.GetFlaggedPosts(userId, offset, limit)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("PostStore.GetFlaggedPosts", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerPostStore) GetFlaggedPostsForChannel(userId string, channelID string, offset int, limit int) (*model.PostList, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.PostStore.GetFlaggedPostsForChannel(userId, channelID, offset, limit)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("PostStore.GetFlaggedPostsForChannel", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerPostStore) GetFlaggedPostsForTeam(userId string, teamID string, offset int, limit int) (*model.PostList, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.PostStore.GetFlaggedPostsForTeam(userId, teamID, offset, limit)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("PostStore.GetFlaggedPostsForTeam", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerPostStore) GetMaxPostSize() int {
|
|
start := timemodule.Now()
|
|
|
|
result := s.PostStore.GetMaxPostSize()
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if true {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("PostStore.GetMaxPostSize", success, elapsed)
|
|
}
|
|
return result
|
|
}
|
|
|
|
func (s *TimerLayerPostStore) GetOldest() (*model.Post, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.PostStore.GetOldest()
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("PostStore.GetOldest", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerPostStore) GetOldestEntityCreationTime() (int64, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.PostStore.GetOldestEntityCreationTime()
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("PostStore.GetOldestEntityCreationTime", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerPostStore) GetParentsForExportAfter(limit int, afterID string) ([]*model.PostForExport, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.PostStore.GetParentsForExportAfter(limit, afterID)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("PostStore.GetParentsForExportAfter", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerPostStore) GetPostAfterTime(channelID string, time int64, collapsedThreads bool) (*model.Post, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.PostStore.GetPostAfterTime(channelID, time, collapsedThreads)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("PostStore.GetPostAfterTime", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerPostStore) GetPostIdAfterTime(channelID string, time int64, collapsedThreads bool) (string, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.PostStore.GetPostIdAfterTime(channelID, time, collapsedThreads)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("PostStore.GetPostIdAfterTime", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerPostStore) GetPostIdBeforeTime(channelID string, time int64, collapsedThreads bool) (string, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.PostStore.GetPostIdBeforeTime(channelID, time, collapsedThreads)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("PostStore.GetPostIdBeforeTime", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerPostStore) GetPosts(options model.GetPostsOptions, allowFromCache bool) (*model.PostList, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.PostStore.GetPosts(options, allowFromCache)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("PostStore.GetPosts", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerPostStore) GetPostsAfter(options model.GetPostsOptions) (*model.PostList, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.PostStore.GetPostsAfter(options)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("PostStore.GetPostsAfter", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerPostStore) GetPostsBatchForIndexing(startTime int64, endTime int64, limit int) ([]*model.PostForIndexing, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.PostStore.GetPostsBatchForIndexing(startTime, endTime, limit)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("PostStore.GetPostsBatchForIndexing", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerPostStore) GetPostsBefore(options model.GetPostsOptions) (*model.PostList, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.PostStore.GetPostsBefore(options)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("PostStore.GetPostsBefore", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerPostStore) GetPostsByIds(postIds []string) ([]*model.Post, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.PostStore.GetPostsByIds(postIds)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("PostStore.GetPostsByIds", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerPostStore) GetPostsCreatedAt(channelID string, time int64) ([]*model.Post, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.PostStore.GetPostsCreatedAt(channelID, time)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("PostStore.GetPostsCreatedAt", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerPostStore) GetPostsSince(options model.GetPostsSinceOptions, allowFromCache bool) (*model.PostList, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.PostStore.GetPostsSince(options, allowFromCache)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("PostStore.GetPostsSince", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerPostStore) GetRepliesForExport(parentID string) ([]*model.ReplyForExport, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.PostStore.GetRepliesForExport(parentID)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("PostStore.GetRepliesForExport", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerPostStore) GetSingle(id string) (*model.Post, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.PostStore.GetSingle(id)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("PostStore.GetSingle", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerPostStore) InvalidateLastPostTimeCache(channelID string) {
|
|
start := timemodule.Now()
|
|
|
|
s.PostStore.InvalidateLastPostTimeCache(channelID)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if true {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("PostStore.InvalidateLastPostTimeCache", success, elapsed)
|
|
}
|
|
}
|
|
|
|
func (s *TimerLayerPostStore) Overwrite(post *model.Post) (*model.Post, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.PostStore.Overwrite(post)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("PostStore.Overwrite", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerPostStore) OverwriteMultiple(posts []*model.Post) ([]*model.Post, int, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, resultVar1, err := s.PostStore.OverwriteMultiple(posts)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("PostStore.OverwriteMultiple", success, elapsed)
|
|
}
|
|
return result, resultVar1, err
|
|
}
|
|
|
|
func (s *TimerLayerPostStore) PermanentDeleteBatch(endTime int64, limit int64) (int64, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.PostStore.PermanentDeleteBatch(endTime, limit)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("PostStore.PermanentDeleteBatch", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerPostStore) PermanentDeleteByChannel(channelID string) error {
|
|
start := timemodule.Now()
|
|
|
|
err := s.PostStore.PermanentDeleteByChannel(channelID)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("PostStore.PermanentDeleteByChannel", success, elapsed)
|
|
}
|
|
return err
|
|
}
|
|
|
|
func (s *TimerLayerPostStore) PermanentDeleteByUser(userId string) error {
|
|
start := timemodule.Now()
|
|
|
|
err := s.PostStore.PermanentDeleteByUser(userId)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("PostStore.PermanentDeleteByUser", success, elapsed)
|
|
}
|
|
return err
|
|
}
|
|
|
|
func (s *TimerLayerPostStore) Save(post *model.Post) (*model.Post, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.PostStore.Save(post)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("PostStore.Save", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerPostStore) SaveMultiple(posts []*model.Post) ([]*model.Post, int, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, resultVar1, err := s.PostStore.SaveMultiple(posts)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("PostStore.SaveMultiple", success, elapsed)
|
|
}
|
|
return result, resultVar1, err
|
|
}
|
|
|
|
func (s *TimerLayerPostStore) Search(teamID string, userId string, params *model.SearchParams) (*model.PostList, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.PostStore.Search(teamID, userId, params)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("PostStore.Search", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerPostStore) SearchPostsInTeamForUser(paramsList []*model.SearchParams, userId string, teamID string, page int, perPage int) (*model.PostSearchResults, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.PostStore.SearchPostsInTeamForUser(paramsList, userId, teamID, page, perPage)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("PostStore.SearchPostsInTeamForUser", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerPostStore) Update(newPost *model.Post, oldPost *model.Post) (*model.Post, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.PostStore.Update(newPost, oldPost)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("PostStore.Update", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerPreferenceStore) CleanupFlagsBatch(limit int64) (int64, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.PreferenceStore.CleanupFlagsBatch(limit)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("PreferenceStore.CleanupFlagsBatch", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerPreferenceStore) Delete(userId string, category string, name string) error {
|
|
start := timemodule.Now()
|
|
|
|
err := s.PreferenceStore.Delete(userId, category, name)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("PreferenceStore.Delete", success, elapsed)
|
|
}
|
|
return err
|
|
}
|
|
|
|
func (s *TimerLayerPreferenceStore) DeleteCategory(userId string, category string) error {
|
|
start := timemodule.Now()
|
|
|
|
err := s.PreferenceStore.DeleteCategory(userId, category)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("PreferenceStore.DeleteCategory", success, elapsed)
|
|
}
|
|
return err
|
|
}
|
|
|
|
func (s *TimerLayerPreferenceStore) DeleteCategoryAndName(category string, name string) error {
|
|
start := timemodule.Now()
|
|
|
|
err := s.PreferenceStore.DeleteCategoryAndName(category, name)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("PreferenceStore.DeleteCategoryAndName", success, elapsed)
|
|
}
|
|
return err
|
|
}
|
|
|
|
func (s *TimerLayerPreferenceStore) Get(userId string, category string, name string) (*model.Preference, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.PreferenceStore.Get(userId, category, name)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("PreferenceStore.Get", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerPreferenceStore) GetAll(userId string) (model.Preferences, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.PreferenceStore.GetAll(userId)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("PreferenceStore.GetAll", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerPreferenceStore) GetCategory(userId string, category string) (model.Preferences, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.PreferenceStore.GetCategory(userId, category)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("PreferenceStore.GetCategory", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerPreferenceStore) PermanentDeleteByUser(userId string) error {
|
|
start := timemodule.Now()
|
|
|
|
err := s.PreferenceStore.PermanentDeleteByUser(userId)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("PreferenceStore.PermanentDeleteByUser", success, elapsed)
|
|
}
|
|
return err
|
|
}
|
|
|
|
func (s *TimerLayerPreferenceStore) Save(preferences *model.Preferences) error {
|
|
start := timemodule.Now()
|
|
|
|
err := s.PreferenceStore.Save(preferences)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("PreferenceStore.Save", success, elapsed)
|
|
}
|
|
return err
|
|
}
|
|
|
|
func (s *TimerLayerProductNoticesStore) Clear(notices []string) error {
|
|
start := timemodule.Now()
|
|
|
|
err := s.ProductNoticesStore.Clear(notices)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("ProductNoticesStore.Clear", success, elapsed)
|
|
}
|
|
return err
|
|
}
|
|
|
|
func (s *TimerLayerProductNoticesStore) ClearOldNotices(currentNotices *model.ProductNotices) error {
|
|
start := timemodule.Now()
|
|
|
|
err := s.ProductNoticesStore.ClearOldNotices(currentNotices)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("ProductNoticesStore.ClearOldNotices", success, elapsed)
|
|
}
|
|
return err
|
|
}
|
|
|
|
func (s *TimerLayerProductNoticesStore) GetViews(userId string) ([]model.ProductNoticeViewState, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.ProductNoticesStore.GetViews(userId)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("ProductNoticesStore.GetViews", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerProductNoticesStore) View(userId string, notices []string) error {
|
|
start := timemodule.Now()
|
|
|
|
err := s.ProductNoticesStore.View(userId, notices)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("ProductNoticesStore.View", success, elapsed)
|
|
}
|
|
return err
|
|
}
|
|
|
|
func (s *TimerLayerReactionStore) BulkGetForPosts(postIds []string) ([]*model.Reaction, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.ReactionStore.BulkGetForPosts(postIds)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("ReactionStore.BulkGetForPosts", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerReactionStore) Delete(reaction *model.Reaction) (*model.Reaction, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.ReactionStore.Delete(reaction)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("ReactionStore.Delete", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerReactionStore) DeleteAllWithEmojiName(emojiName string) error {
|
|
start := timemodule.Now()
|
|
|
|
err := s.ReactionStore.DeleteAllWithEmojiName(emojiName)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("ReactionStore.DeleteAllWithEmojiName", success, elapsed)
|
|
}
|
|
return err
|
|
}
|
|
|
|
func (s *TimerLayerReactionStore) GetForPost(postID string, allowFromCache bool) ([]*model.Reaction, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.ReactionStore.GetForPost(postID, allowFromCache)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("ReactionStore.GetForPost", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerReactionStore) PermanentDeleteBatch(endTime int64, limit int64) (int64, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.ReactionStore.PermanentDeleteBatch(endTime, limit)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("ReactionStore.PermanentDeleteBatch", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerReactionStore) Save(reaction *model.Reaction) (*model.Reaction, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.ReactionStore.Save(reaction)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("ReactionStore.Save", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerRoleStore) AllChannelSchemeRoles() ([]*model.Role, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.RoleStore.AllChannelSchemeRoles()
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("RoleStore.AllChannelSchemeRoles", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerRoleStore) ChannelHigherScopedPermissions(roleNames []string) (map[string]*model.RolePermissions, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.RoleStore.ChannelHigherScopedPermissions(roleNames)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("RoleStore.ChannelHigherScopedPermissions", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerRoleStore) ChannelRolesUnderTeamRole(roleName string) ([]*model.Role, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.RoleStore.ChannelRolesUnderTeamRole(roleName)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("RoleStore.ChannelRolesUnderTeamRole", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerRoleStore) Delete(roleID string) (*model.Role, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.RoleStore.Delete(roleID)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("RoleStore.Delete", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerRoleStore) Get(roleID string) (*model.Role, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.RoleStore.Get(roleID)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("RoleStore.Get", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerRoleStore) GetAll() ([]*model.Role, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.RoleStore.GetAll()
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("RoleStore.GetAll", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerRoleStore) GetByName(name string) (*model.Role, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.RoleStore.GetByName(name)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("RoleStore.GetByName", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerRoleStore) GetByNames(names []string) ([]*model.Role, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.RoleStore.GetByNames(names)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("RoleStore.GetByNames", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerRoleStore) PermanentDeleteAll() error {
|
|
start := timemodule.Now()
|
|
|
|
err := s.RoleStore.PermanentDeleteAll()
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("RoleStore.PermanentDeleteAll", success, elapsed)
|
|
}
|
|
return err
|
|
}
|
|
|
|
func (s *TimerLayerRoleStore) Save(role *model.Role) (*model.Role, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.RoleStore.Save(role)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("RoleStore.Save", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerSchemeStore) CountByScope(scope string) (int64, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.SchemeStore.CountByScope(scope)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("SchemeStore.CountByScope", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerSchemeStore) CountWithoutPermission(scope string, permissionID string, roleScope model.RoleScope, roleType model.RoleType) (int64, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.SchemeStore.CountWithoutPermission(scope, permissionID, roleScope, roleType)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("SchemeStore.CountWithoutPermission", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerSchemeStore) Delete(schemeID string) (*model.Scheme, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.SchemeStore.Delete(schemeID)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("SchemeStore.Delete", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerSchemeStore) Get(schemeID string) (*model.Scheme, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.SchemeStore.Get(schemeID)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("SchemeStore.Get", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerSchemeStore) GetAllPage(scope string, offset int, limit int) ([]*model.Scheme, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.SchemeStore.GetAllPage(scope, offset, limit)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("SchemeStore.GetAllPage", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerSchemeStore) GetByName(schemeName string) (*model.Scheme, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.SchemeStore.GetByName(schemeName)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("SchemeStore.GetByName", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerSchemeStore) PermanentDeleteAll() error {
|
|
start := timemodule.Now()
|
|
|
|
err := s.SchemeStore.PermanentDeleteAll()
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("SchemeStore.PermanentDeleteAll", success, elapsed)
|
|
}
|
|
return err
|
|
}
|
|
|
|
func (s *TimerLayerSchemeStore) Save(scheme *model.Scheme) (*model.Scheme, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.SchemeStore.Save(scheme)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("SchemeStore.Save", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerSessionStore) AnalyticsSessionCount() (int64, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.SessionStore.AnalyticsSessionCount()
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("SessionStore.AnalyticsSessionCount", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerSessionStore) Cleanup(expiryTime int64, batchSize int64) {
|
|
start := timemodule.Now()
|
|
|
|
s.SessionStore.Cleanup(expiryTime, batchSize)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if true {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("SessionStore.Cleanup", success, elapsed)
|
|
}
|
|
}
|
|
|
|
func (s *TimerLayerSessionStore) Get(ctx context.Context, sessionIDOrToken string) (*model.Session, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.SessionStore.Get(ctx, sessionIDOrToken)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("SessionStore.Get", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerSessionStore) GetSessions(userId string) ([]*model.Session, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.SessionStore.GetSessions(userId)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("SessionStore.GetSessions", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerSessionStore) GetSessionsExpired(thresholdMillis int64, mobileOnly bool, unnotifiedOnly bool) ([]*model.Session, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.SessionStore.GetSessionsExpired(thresholdMillis, mobileOnly, unnotifiedOnly)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("SessionStore.GetSessionsExpired", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerSessionStore) GetSessionsWithActiveDeviceIds(userId string) ([]*model.Session, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.SessionStore.GetSessionsWithActiveDeviceIds(userId)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("SessionStore.GetSessionsWithActiveDeviceIds", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerSessionStore) PermanentDeleteSessionsByUser(teamID string) error {
|
|
start := timemodule.Now()
|
|
|
|
err := s.SessionStore.PermanentDeleteSessionsByUser(teamID)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("SessionStore.PermanentDeleteSessionsByUser", success, elapsed)
|
|
}
|
|
return err
|
|
}
|
|
|
|
func (s *TimerLayerSessionStore) Remove(sessionIDOrToken string) error {
|
|
start := timemodule.Now()
|
|
|
|
err := s.SessionStore.Remove(sessionIDOrToken)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("SessionStore.Remove", success, elapsed)
|
|
}
|
|
return err
|
|
}
|
|
|
|
func (s *TimerLayerSessionStore) RemoveAllSessions() error {
|
|
start := timemodule.Now()
|
|
|
|
err := s.SessionStore.RemoveAllSessions()
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("SessionStore.RemoveAllSessions", success, elapsed)
|
|
}
|
|
return err
|
|
}
|
|
|
|
func (s *TimerLayerSessionStore) Save(session *model.Session) (*model.Session, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.SessionStore.Save(session)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("SessionStore.Save", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerSessionStore) UpdateDeviceId(id string, deviceID string, expiresAt int64) (string, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.SessionStore.UpdateDeviceId(id, deviceID, expiresAt)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("SessionStore.UpdateDeviceId", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerSessionStore) UpdateExpiredNotify(sessionid string, notified bool) error {
|
|
start := timemodule.Now()
|
|
|
|
err := s.SessionStore.UpdateExpiredNotify(sessionid, notified)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("SessionStore.UpdateExpiredNotify", success, elapsed)
|
|
}
|
|
return err
|
|
}
|
|
|
|
func (s *TimerLayerSessionStore) UpdateExpiresAt(sessionID string, time int64) error {
|
|
start := timemodule.Now()
|
|
|
|
err := s.SessionStore.UpdateExpiresAt(sessionID, time)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("SessionStore.UpdateExpiresAt", success, elapsed)
|
|
}
|
|
return err
|
|
}
|
|
|
|
func (s *TimerLayerSessionStore) UpdateLastActivityAt(sessionID string, time int64) error {
|
|
start := timemodule.Now()
|
|
|
|
err := s.SessionStore.UpdateLastActivityAt(sessionID, time)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("SessionStore.UpdateLastActivityAt", success, elapsed)
|
|
}
|
|
return err
|
|
}
|
|
|
|
func (s *TimerLayerSessionStore) UpdateProps(session *model.Session) error {
|
|
start := timemodule.Now()
|
|
|
|
err := s.SessionStore.UpdateProps(session)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("SessionStore.UpdateProps", success, elapsed)
|
|
}
|
|
return err
|
|
}
|
|
|
|
func (s *TimerLayerSessionStore) UpdateRoles(userId string, roles string) (string, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.SessionStore.UpdateRoles(userId, roles)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("SessionStore.UpdateRoles", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerStatusStore) Get(userId string) (*model.Status, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.StatusStore.Get(userId)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("StatusStore.Get", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerStatusStore) GetByIds(userIds []string) ([]*model.Status, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.StatusStore.GetByIds(userIds)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("StatusStore.GetByIds", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerStatusStore) GetTotalActiveUsersCount() (int64, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.StatusStore.GetTotalActiveUsersCount()
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("StatusStore.GetTotalActiveUsersCount", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerStatusStore) ResetAll() error {
|
|
start := timemodule.Now()
|
|
|
|
err := s.StatusStore.ResetAll()
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("StatusStore.ResetAll", success, elapsed)
|
|
}
|
|
return err
|
|
}
|
|
|
|
func (s *TimerLayerStatusStore) SaveOrUpdate(status *model.Status) error {
|
|
start := timemodule.Now()
|
|
|
|
err := s.StatusStore.SaveOrUpdate(status)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("StatusStore.SaveOrUpdate", success, elapsed)
|
|
}
|
|
return err
|
|
}
|
|
|
|
func (s *TimerLayerStatusStore) UpdateLastActivityAt(userId string, lastActivityAt int64) error {
|
|
start := timemodule.Now()
|
|
|
|
err := s.StatusStore.UpdateLastActivityAt(userId, lastActivityAt)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("StatusStore.UpdateLastActivityAt", success, elapsed)
|
|
}
|
|
return err
|
|
}
|
|
|
|
func (s *TimerLayerSystemStore) Get() (model.StringMap, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.SystemStore.Get()
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("SystemStore.Get", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerSystemStore) GetByName(name string) (*model.System, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.SystemStore.GetByName(name)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("SystemStore.GetByName", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerSystemStore) InsertIfExists(system *model.System) (*model.System, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.SystemStore.InsertIfExists(system)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("SystemStore.InsertIfExists", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerSystemStore) PermanentDeleteByName(name string) (*model.System, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.SystemStore.PermanentDeleteByName(name)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("SystemStore.PermanentDeleteByName", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerSystemStore) Save(system *model.System) error {
|
|
start := timemodule.Now()
|
|
|
|
err := s.SystemStore.Save(system)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("SystemStore.Save", success, elapsed)
|
|
}
|
|
return err
|
|
}
|
|
|
|
func (s *TimerLayerSystemStore) SaveOrUpdate(system *model.System) error {
|
|
start := timemodule.Now()
|
|
|
|
err := s.SystemStore.SaveOrUpdate(system)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("SystemStore.SaveOrUpdate", success, elapsed)
|
|
}
|
|
return err
|
|
}
|
|
|
|
func (s *TimerLayerSystemStore) SaveOrUpdateWithWarnMetricHandling(system *model.System) error {
|
|
start := timemodule.Now()
|
|
|
|
err := s.SystemStore.SaveOrUpdateWithWarnMetricHandling(system)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("SystemStore.SaveOrUpdateWithWarnMetricHandling", success, elapsed)
|
|
}
|
|
return err
|
|
}
|
|
|
|
func (s *TimerLayerSystemStore) Update(system *model.System) error {
|
|
start := timemodule.Now()
|
|
|
|
err := s.SystemStore.Update(system)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("SystemStore.Update", success, elapsed)
|
|
}
|
|
return err
|
|
}
|
|
|
|
func (s *TimerLayerTeamStore) AnalyticsGetTeamCountForScheme(schemeID string) (int64, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.TeamStore.AnalyticsGetTeamCountForScheme(schemeID)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("TeamStore.AnalyticsGetTeamCountForScheme", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerTeamStore) AnalyticsPrivateTeamCount() (int64, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.TeamStore.AnalyticsPrivateTeamCount()
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("TeamStore.AnalyticsPrivateTeamCount", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerTeamStore) AnalyticsPublicTeamCount() (int64, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.TeamStore.AnalyticsPublicTeamCount()
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("TeamStore.AnalyticsPublicTeamCount", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerTeamStore) AnalyticsTeamCount(includeDeleted bool) (int64, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.TeamStore.AnalyticsTeamCount(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("TeamStore.AnalyticsTeamCount", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerTeamStore) ClearAllCustomRoleAssignments() error {
|
|
start := timemodule.Now()
|
|
|
|
err := s.TeamStore.ClearAllCustomRoleAssignments()
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("TeamStore.ClearAllCustomRoleAssignments", success, elapsed)
|
|
}
|
|
return err
|
|
}
|
|
|
|
func (s *TimerLayerTeamStore) ClearCaches() {
|
|
start := timemodule.Now()
|
|
|
|
s.TeamStore.ClearCaches()
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if true {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("TeamStore.ClearCaches", success, elapsed)
|
|
}
|
|
}
|
|
|
|
func (s *TimerLayerTeamStore) Get(id string) (*model.Team, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.TeamStore.Get(id)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("TeamStore.Get", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerTeamStore) GetActiveMemberCount(teamID string, restrictions *model.ViewUsersRestrictions) (int64, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.TeamStore.GetActiveMemberCount(teamID, restrictions)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("TeamStore.GetActiveMemberCount", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerTeamStore) GetAll() ([]*model.Team, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.TeamStore.GetAll()
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("TeamStore.GetAll", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerTeamStore) GetAllForExportAfter(limit int, afterID string) ([]*model.TeamForExport, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.TeamStore.GetAllForExportAfter(limit, afterID)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("TeamStore.GetAllForExportAfter", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerTeamStore) GetAllPage(offset int, limit int) ([]*model.Team, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.TeamStore.GetAllPage(offset, limit)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("TeamStore.GetAllPage", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerTeamStore) GetAllPrivateTeamListing() ([]*model.Team, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.TeamStore.GetAllPrivateTeamListing()
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("TeamStore.GetAllPrivateTeamListing", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerTeamStore) GetAllPrivateTeamPageListing(offset int, limit int) ([]*model.Team, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.TeamStore.GetAllPrivateTeamPageListing(offset, limit)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("TeamStore.GetAllPrivateTeamPageListing", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerTeamStore) GetAllPublicTeamPageListing(offset int, limit int) ([]*model.Team, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.TeamStore.GetAllPublicTeamPageListing(offset, limit)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("TeamStore.GetAllPublicTeamPageListing", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerTeamStore) GetAllTeamListing() ([]*model.Team, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.TeamStore.GetAllTeamListing()
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("TeamStore.GetAllTeamListing", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerTeamStore) GetAllTeamPageListing(offset int, limit int) ([]*model.Team, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.TeamStore.GetAllTeamPageListing(offset, limit)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("TeamStore.GetAllTeamPageListing", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerTeamStore) GetByInviteId(inviteID string) (*model.Team, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.TeamStore.GetByInviteId(inviteID)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("TeamStore.GetByInviteId", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerTeamStore) GetByName(name string) (*model.Team, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.TeamStore.GetByName(name)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("TeamStore.GetByName", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerTeamStore) GetByNames(name []string) ([]*model.Team, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.TeamStore.GetByNames(name)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("TeamStore.GetByNames", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerTeamStore) GetChannelUnreadsForAllTeams(excludeTeamID string, userId string) ([]*model.ChannelUnread, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.TeamStore.GetChannelUnreadsForAllTeams(excludeTeamID, userId)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("TeamStore.GetChannelUnreadsForAllTeams", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerTeamStore) GetChannelUnreadsForTeam(teamID string, userId string) ([]*model.ChannelUnread, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.TeamStore.GetChannelUnreadsForTeam(teamID, userId)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("TeamStore.GetChannelUnreadsForTeam", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerTeamStore) GetMember(ctx context.Context, teamID string, userId string) (*model.TeamMember, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.TeamStore.GetMember(ctx, teamID, userId)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("TeamStore.GetMember", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerTeamStore) GetMembers(teamID string, offset int, limit int, teamMembersGetOptions *model.TeamMembersGetOptions) ([]*model.TeamMember, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.TeamStore.GetMembers(teamID, offset, limit, teamMembersGetOptions)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("TeamStore.GetMembers", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerTeamStore) GetMembersByIds(teamID string, userIds []string, restrictions *model.ViewUsersRestrictions) ([]*model.TeamMember, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.TeamStore.GetMembersByIds(teamID, userIds, restrictions)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("TeamStore.GetMembersByIds", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerTeamStore) GetTeamMembersForExport(userId string) ([]*model.TeamMemberForExport, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.TeamStore.GetTeamMembersForExport(userId)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("TeamStore.GetTeamMembersForExport", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerTeamStore) GetTeamsByScheme(schemeID string, offset int, limit int) ([]*model.Team, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.TeamStore.GetTeamsByScheme(schemeID, offset, limit)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("TeamStore.GetTeamsByScheme", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerTeamStore) GetTeamsByUserId(userId string) ([]*model.Team, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.TeamStore.GetTeamsByUserId(userId)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("TeamStore.GetTeamsByUserId", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerTeamStore) GetTeamsForUser(ctx context.Context, userId string) ([]*model.TeamMember, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.TeamStore.GetTeamsForUser(ctx, userId)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("TeamStore.GetTeamsForUser", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerTeamStore) GetTeamsForUserWithPagination(userId string, page int, perPage int) ([]*model.TeamMember, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.TeamStore.GetTeamsForUserWithPagination(userId, page, perPage)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("TeamStore.GetTeamsForUserWithPagination", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerTeamStore) GetTotalMemberCount(teamID string, restrictions *model.ViewUsersRestrictions) (int64, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.TeamStore.GetTotalMemberCount(teamID, restrictions)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("TeamStore.GetTotalMemberCount", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerTeamStore) GetUserTeamIds(userId string, allowFromCache bool) ([]string, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.TeamStore.GetUserTeamIds(userId, allowFromCache)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("TeamStore.GetUserTeamIds", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerTeamStore) GroupSyncedTeamCount() (int64, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.TeamStore.GroupSyncedTeamCount()
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("TeamStore.GroupSyncedTeamCount", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerTeamStore) InvalidateAllTeamIdsForUser(userId string) {
|
|
start := timemodule.Now()
|
|
|
|
s.TeamStore.InvalidateAllTeamIdsForUser(userId)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if true {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("TeamStore.InvalidateAllTeamIdsForUser", success, elapsed)
|
|
}
|
|
}
|
|
|
|
func (s *TimerLayerTeamStore) MigrateTeamMembers(fromTeamID string, fromUserId string) (map[string]string, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.TeamStore.MigrateTeamMembers(fromTeamID, fromUserId)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("TeamStore.MigrateTeamMembers", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerTeamStore) PermanentDelete(teamID string) error {
|
|
start := timemodule.Now()
|
|
|
|
err := s.TeamStore.PermanentDelete(teamID)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("TeamStore.PermanentDelete", success, elapsed)
|
|
}
|
|
return err
|
|
}
|
|
|
|
func (s *TimerLayerTeamStore) RemoveAllMembersByTeam(teamID string) error {
|
|
start := timemodule.Now()
|
|
|
|
err := s.TeamStore.RemoveAllMembersByTeam(teamID)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("TeamStore.RemoveAllMembersByTeam", success, elapsed)
|
|
}
|
|
return err
|
|
}
|
|
|
|
func (s *TimerLayerTeamStore) RemoveAllMembersByUser(userId string) error {
|
|
start := timemodule.Now()
|
|
|
|
err := s.TeamStore.RemoveAllMembersByUser(userId)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("TeamStore.RemoveAllMembersByUser", success, elapsed)
|
|
}
|
|
return err
|
|
}
|
|
|
|
func (s *TimerLayerTeamStore) RemoveMember(teamID string, userId string) error {
|
|
start := timemodule.Now()
|
|
|
|
err := s.TeamStore.RemoveMember(teamID, userId)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("TeamStore.RemoveMember", success, elapsed)
|
|
}
|
|
return err
|
|
}
|
|
|
|
func (s *TimerLayerTeamStore) RemoveMembers(teamID string, userIds []string) error {
|
|
start := timemodule.Now()
|
|
|
|
err := s.TeamStore.RemoveMembers(teamID, userIds)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("TeamStore.RemoveMembers", success, elapsed)
|
|
}
|
|
return err
|
|
}
|
|
|
|
func (s *TimerLayerTeamStore) ResetAllTeamSchemes() error {
|
|
start := timemodule.Now()
|
|
|
|
err := s.TeamStore.ResetAllTeamSchemes()
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("TeamStore.ResetAllTeamSchemes", success, elapsed)
|
|
}
|
|
return err
|
|
}
|
|
|
|
func (s *TimerLayerTeamStore) Save(team *model.Team) (*model.Team, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.TeamStore.Save(team)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("TeamStore.Save", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerTeamStore) SaveMember(member *model.TeamMember, maxUsersPerTeam int) (*model.TeamMember, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.TeamStore.SaveMember(member, maxUsersPerTeam)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("TeamStore.SaveMember", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerTeamStore) SaveMultipleMembers(members []*model.TeamMember, maxUsersPerTeam int) ([]*model.TeamMember, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.TeamStore.SaveMultipleMembers(members, maxUsersPerTeam)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("TeamStore.SaveMultipleMembers", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerTeamStore) SearchAll(term string, opts *model.TeamSearch) ([]*model.Team, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.TeamStore.SearchAll(term, opts)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("TeamStore.SearchAll", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerTeamStore) SearchAllPaged(term string, opts *model.TeamSearch) ([]*model.Team, int64, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, resultVar1, err := s.TeamStore.SearchAllPaged(term, opts)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("TeamStore.SearchAllPaged", success, elapsed)
|
|
}
|
|
return result, resultVar1, err
|
|
}
|
|
|
|
func (s *TimerLayerTeamStore) SearchOpen(term string) ([]*model.Team, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.TeamStore.SearchOpen(term)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("TeamStore.SearchOpen", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerTeamStore) SearchPrivate(term string) ([]*model.Team, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.TeamStore.SearchPrivate(term)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("TeamStore.SearchPrivate", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerTeamStore) Update(team *model.Team) (*model.Team, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.TeamStore.Update(team)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("TeamStore.Update", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerTeamStore) UpdateLastTeamIconUpdate(teamID string, curTime int64) error {
|
|
start := timemodule.Now()
|
|
|
|
err := s.TeamStore.UpdateLastTeamIconUpdate(teamID, curTime)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("TeamStore.UpdateLastTeamIconUpdate", success, elapsed)
|
|
}
|
|
return err
|
|
}
|
|
|
|
func (s *TimerLayerTeamStore) UpdateMember(member *model.TeamMember) (*model.TeamMember, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.TeamStore.UpdateMember(member)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("TeamStore.UpdateMember", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerTeamStore) UpdateMembersRole(teamID string, userIDs []string) error {
|
|
start := timemodule.Now()
|
|
|
|
err := s.TeamStore.UpdateMembersRole(teamID, userIDs)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("TeamStore.UpdateMembersRole", success, elapsed)
|
|
}
|
|
return err
|
|
}
|
|
|
|
func (s *TimerLayerTeamStore) UpdateMultipleMembers(members []*model.TeamMember) ([]*model.TeamMember, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.TeamStore.UpdateMultipleMembers(members)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("TeamStore.UpdateMultipleMembers", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerTeamStore) UserBelongsToTeams(userId string, teamIds []string) (bool, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.TeamStore.UserBelongsToTeams(userId, teamIds)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("TeamStore.UserBelongsToTeams", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerTermsOfServiceStore) Get(id string, allowFromCache bool) (*model.TermsOfService, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.TermsOfServiceStore.Get(id, allowFromCache)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("TermsOfServiceStore.Get", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerTermsOfServiceStore) GetLatest(allowFromCache bool) (*model.TermsOfService, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.TermsOfServiceStore.GetLatest(allowFromCache)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("TermsOfServiceStore.GetLatest", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerTermsOfServiceStore) Save(termsOfService *model.TermsOfService) (*model.TermsOfService, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.TermsOfServiceStore.Save(termsOfService)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("TermsOfServiceStore.Save", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerThreadStore) CollectThreadsWithNewerReplies(userId string, channelIds []string, timestamp int64) ([]string, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.ThreadStore.CollectThreadsWithNewerReplies(userId, channelIds, timestamp)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("ThreadStore.CollectThreadsWithNewerReplies", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerThreadStore) Delete(postId string) error {
|
|
start := timemodule.Now()
|
|
|
|
err := s.ThreadStore.Delete(postId)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("ThreadStore.Delete", success, elapsed)
|
|
}
|
|
return err
|
|
}
|
|
|
|
func (s *TimerLayerThreadStore) DeleteMembershipForUser(userId string, postID string) error {
|
|
start := timemodule.Now()
|
|
|
|
err := s.ThreadStore.DeleteMembershipForUser(userId, postID)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("ThreadStore.DeleteMembershipForUser", success, elapsed)
|
|
}
|
|
return err
|
|
}
|
|
|
|
func (s *TimerLayerThreadStore) Get(id string) (*model.Thread, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.ThreadStore.Get(id)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("ThreadStore.Get", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerThreadStore) GetMembershipForUser(userId string, postID string) (*model.ThreadMembership, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.ThreadStore.GetMembershipForUser(userId, postID)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("ThreadStore.GetMembershipForUser", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerThreadStore) GetMembershipsForUser(userId string, teamID string) ([]*model.ThreadMembership, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.ThreadStore.GetMembershipsForUser(userId, teamID)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("ThreadStore.GetMembershipsForUser", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerThreadStore) GetPosts(threadId string, since int64) ([]*model.Post, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.ThreadStore.GetPosts(threadId, since)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("ThreadStore.GetPosts", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerThreadStore) GetThreadForUser(userId string, teamId string, threadId string, extended bool) (*model.ThreadResponse, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.ThreadStore.GetThreadForUser(userId, teamId, threadId, extended)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("ThreadStore.GetThreadForUser", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerThreadStore) GetThreadMentionsForUserPerChannel(userId string, teamId string) (map[string]int64, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.ThreadStore.GetThreadMentionsForUserPerChannel(userId, teamId)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("ThreadStore.GetThreadMentionsForUserPerChannel", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerThreadStore) GetThreadsForUser(userId string, teamId string, opts model.GetUserThreadsOpts) (*model.Threads, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.ThreadStore.GetThreadsForUser(userId, teamId, opts)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("ThreadStore.GetThreadsForUser", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerThreadStore) MaintainMembership(userId string, postID string, following bool, incrementMentions bool, updateFollowing bool, updateViewedTimestamp bool) error {
|
|
start := timemodule.Now()
|
|
|
|
err := s.ThreadStore.MaintainMembership(userId, postID, following, incrementMentions, updateFollowing, updateViewedTimestamp)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("ThreadStore.MaintainMembership", success, elapsed)
|
|
}
|
|
return err
|
|
}
|
|
|
|
func (s *TimerLayerThreadStore) MarkAllAsRead(userId string, teamID string) error {
|
|
start := timemodule.Now()
|
|
|
|
err := s.ThreadStore.MarkAllAsRead(userId, teamID)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("ThreadStore.MarkAllAsRead", success, elapsed)
|
|
}
|
|
return err
|
|
}
|
|
|
|
func (s *TimerLayerThreadStore) MarkAsRead(userId string, threadID string, timestamp int64) error {
|
|
start := timemodule.Now()
|
|
|
|
err := s.ThreadStore.MarkAsRead(userId, threadID, timestamp)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("ThreadStore.MarkAsRead", success, elapsed)
|
|
}
|
|
return err
|
|
}
|
|
|
|
func (s *TimerLayerThreadStore) Save(thread *model.Thread) (*model.Thread, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.ThreadStore.Save(thread)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("ThreadStore.Save", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerThreadStore) SaveMembership(membership *model.ThreadMembership) (*model.ThreadMembership, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.ThreadStore.SaveMembership(membership)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("ThreadStore.SaveMembership", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerThreadStore) SaveMultiple(thread []*model.Thread) ([]*model.Thread, int, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, resultVar1, err := s.ThreadStore.SaveMultiple(thread)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("ThreadStore.SaveMultiple", success, elapsed)
|
|
}
|
|
return result, resultVar1, err
|
|
}
|
|
|
|
func (s *TimerLayerThreadStore) Update(thread *model.Thread) (*model.Thread, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.ThreadStore.Update(thread)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("ThreadStore.Update", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerThreadStore) UpdateMembership(membership *model.ThreadMembership) (*model.ThreadMembership, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.ThreadStore.UpdateMembership(membership)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("ThreadStore.UpdateMembership", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerThreadStore) UpdateUnreadsByChannel(userId string, changedThreads []string, timestamp int64, updateViewedTimestamp bool) error {
|
|
start := timemodule.Now()
|
|
|
|
err := s.ThreadStore.UpdateUnreadsByChannel(userId, changedThreads, timestamp, updateViewedTimestamp)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("ThreadStore.UpdateUnreadsByChannel", success, elapsed)
|
|
}
|
|
return err
|
|
}
|
|
|
|
func (s *TimerLayerTokenStore) Cleanup() {
|
|
start := timemodule.Now()
|
|
|
|
s.TokenStore.Cleanup()
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if true {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("TokenStore.Cleanup", success, elapsed)
|
|
}
|
|
}
|
|
|
|
func (s *TimerLayerTokenStore) Delete(token string) error {
|
|
start := timemodule.Now()
|
|
|
|
err := s.TokenStore.Delete(token)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("TokenStore.Delete", success, elapsed)
|
|
}
|
|
return err
|
|
}
|
|
|
|
func (s *TimerLayerTokenStore) GetByToken(token string) (*model.Token, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.TokenStore.GetByToken(token)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("TokenStore.GetByToken", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerTokenStore) RemoveAllTokensByType(tokenType string) error {
|
|
start := timemodule.Now()
|
|
|
|
err := s.TokenStore.RemoveAllTokensByType(tokenType)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("TokenStore.RemoveAllTokensByType", success, elapsed)
|
|
}
|
|
return err
|
|
}
|
|
|
|
func (s *TimerLayerTokenStore) Save(recovery *model.Token) error {
|
|
start := timemodule.Now()
|
|
|
|
err := s.TokenStore.Save(recovery)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("TokenStore.Save", success, elapsed)
|
|
}
|
|
return err
|
|
}
|
|
|
|
func (s *TimerLayerUploadSessionStore) Delete(id string) error {
|
|
start := timemodule.Now()
|
|
|
|
err := s.UploadSessionStore.Delete(id)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("UploadSessionStore.Delete", success, elapsed)
|
|
}
|
|
return err
|
|
}
|
|
|
|
func (s *TimerLayerUploadSessionStore) Get(id string) (*model.UploadSession, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.UploadSessionStore.Get(id)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("UploadSessionStore.Get", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerUploadSessionStore) GetForUser(userId string) ([]*model.UploadSession, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.UploadSessionStore.GetForUser(userId)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("UploadSessionStore.GetForUser", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerUploadSessionStore) Save(session *model.UploadSession) (*model.UploadSession, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.UploadSessionStore.Save(session)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("UploadSessionStore.Save", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerUploadSessionStore) Update(session *model.UploadSession) error {
|
|
start := timemodule.Now()
|
|
|
|
err := s.UploadSessionStore.Update(session)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("UploadSessionStore.Update", success, elapsed)
|
|
}
|
|
return err
|
|
}
|
|
|
|
func (s *TimerLayerUserStore) AnalyticsActiveCount(time int64, options model.UserCountOptions) (int64, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.UserStore.AnalyticsActiveCount(time, options)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("UserStore.AnalyticsActiveCount", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerUserStore) AnalyticsActiveCountForPeriod(startTime int64, endTime int64, options model.UserCountOptions) (int64, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.UserStore.AnalyticsActiveCountForPeriod(startTime, endTime, options)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("UserStore.AnalyticsActiveCountForPeriod", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerUserStore) AnalyticsGetExternalUsers(hostDomain string) (bool, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.UserStore.AnalyticsGetExternalUsers(hostDomain)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("UserStore.AnalyticsGetExternalUsers", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerUserStore) AnalyticsGetGuestCount() (int64, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.UserStore.AnalyticsGetGuestCount()
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("UserStore.AnalyticsGetGuestCount", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerUserStore) AnalyticsGetInactiveUsersCount() (int64, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.UserStore.AnalyticsGetInactiveUsersCount()
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("UserStore.AnalyticsGetInactiveUsersCount", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerUserStore) AnalyticsGetSystemAdminCount() (int64, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.UserStore.AnalyticsGetSystemAdminCount()
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("UserStore.AnalyticsGetSystemAdminCount", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerUserStore) AutocompleteUsersInChannel(teamID string, channelID string, term string, options *model.UserSearchOptions) (*model.UserAutocompleteInChannel, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.UserStore.AutocompleteUsersInChannel(teamID, channelID, term, options)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("UserStore.AutocompleteUsersInChannel", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerUserStore) ClearAllCustomRoleAssignments() error {
|
|
start := timemodule.Now()
|
|
|
|
err := s.UserStore.ClearAllCustomRoleAssignments()
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("UserStore.ClearAllCustomRoleAssignments", success, elapsed)
|
|
}
|
|
return err
|
|
}
|
|
|
|
func (s *TimerLayerUserStore) ClearCaches() {
|
|
start := timemodule.Now()
|
|
|
|
s.UserStore.ClearCaches()
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if true {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("UserStore.ClearCaches", success, elapsed)
|
|
}
|
|
}
|
|
|
|
func (s *TimerLayerUserStore) Count(options model.UserCountOptions) (int64, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.UserStore.Count(options)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("UserStore.Count", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerUserStore) DeactivateGuests() ([]string, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.UserStore.DeactivateGuests()
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("UserStore.DeactivateGuests", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerUserStore) DemoteUserToGuest(userID string) (*model.User, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.UserStore.DemoteUserToGuest(userID)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("UserStore.DemoteUserToGuest", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerUserStore) Get(ctx context.Context, id string) (*model.User, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.UserStore.Get(ctx, id)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("UserStore.Get", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerUserStore) GetAll() ([]*model.User, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.UserStore.GetAll()
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("UserStore.GetAll", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerUserStore) GetAllAfter(limit int, afterID string) ([]*model.User, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.UserStore.GetAllAfter(limit, afterID)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("UserStore.GetAllAfter", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerUserStore) GetAllNotInAuthService(authServices []string) ([]*model.User, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.UserStore.GetAllNotInAuthService(authServices)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("UserStore.GetAllNotInAuthService", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerUserStore) GetAllProfiles(options *model.UserGetOptions) ([]*model.User, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.UserStore.GetAllProfiles(options)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("UserStore.GetAllProfiles", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerUserStore) GetAllProfilesInChannel(ctx context.Context, channelId string, allowFromCache bool) (map[string]*model.User, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.UserStore.GetAllProfilesInChannel(ctx, channelId, allowFromCache)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("UserStore.GetAllProfilesInChannel", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerUserStore) GetAllUsingAuthService(authService string) ([]*model.User, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.UserStore.GetAllUsingAuthService(authService)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("UserStore.GetAllUsingAuthService", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerUserStore) GetAnyUnreadPostCountForChannel(userId string, channelID string) (int64, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.UserStore.GetAnyUnreadPostCountForChannel(userId, channelID)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("UserStore.GetAnyUnreadPostCountForChannel", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerUserStore) GetByAuth(authData *string, authService string) (*model.User, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.UserStore.GetByAuth(authData, authService)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("UserStore.GetByAuth", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerUserStore) GetByEmail(email string) (*model.User, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.UserStore.GetByEmail(email)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("UserStore.GetByEmail", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerUserStore) GetByUsername(username string) (*model.User, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.UserStore.GetByUsername(username)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("UserStore.GetByUsername", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerUserStore) GetChannelGroupUsers(channelID string) ([]*model.User, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.UserStore.GetChannelGroupUsers(channelID)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("UserStore.GetChannelGroupUsers", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerUserStore) GetEtagForAllProfiles() string {
|
|
start := timemodule.Now()
|
|
|
|
result := s.UserStore.GetEtagForAllProfiles()
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if true {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("UserStore.GetEtagForAllProfiles", success, elapsed)
|
|
}
|
|
return result
|
|
}
|
|
|
|
func (s *TimerLayerUserStore) GetEtagForProfiles(teamID string) string {
|
|
start := timemodule.Now()
|
|
|
|
result := s.UserStore.GetEtagForProfiles(teamID)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if true {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("UserStore.GetEtagForProfiles", success, elapsed)
|
|
}
|
|
return result
|
|
}
|
|
|
|
func (s *TimerLayerUserStore) GetEtagForProfilesNotInTeam(teamID string) string {
|
|
start := timemodule.Now()
|
|
|
|
result := s.UserStore.GetEtagForProfilesNotInTeam(teamID)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if true {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("UserStore.GetEtagForProfilesNotInTeam", success, elapsed)
|
|
}
|
|
return result
|
|
}
|
|
|
|
func (s *TimerLayerUserStore) GetForLogin(loginID string, allowSignInWithUsername bool, allowSignInWithEmail bool) (*model.User, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.UserStore.GetForLogin(loginID, allowSignInWithUsername, allowSignInWithEmail)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("UserStore.GetForLogin", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerUserStore) GetKnownUsers(userID string) ([]string, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.UserStore.GetKnownUsers(userID)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("UserStore.GetKnownUsers", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerUserStore) GetMany(ctx context.Context, ids []string) ([]*model.User, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.UserStore.GetMany(ctx, ids)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("UserStore.GetMany", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerUserStore) GetNewUsersForTeam(teamID string, offset int, limit int, viewRestrictions *model.ViewUsersRestrictions) ([]*model.User, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.UserStore.GetNewUsersForTeam(teamID, offset, limit, viewRestrictions)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("UserStore.GetNewUsersForTeam", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerUserStore) GetProfileByGroupChannelIdsForUser(userId string, channelIds []string) (map[string][]*model.User, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.UserStore.GetProfileByGroupChannelIdsForUser(userId, channelIds)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("UserStore.GetProfileByGroupChannelIdsForUser", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerUserStore) GetProfileByIds(ctx context.Context, userIds []string, options *store.UserGetByIdsOpts, allowFromCache bool) ([]*model.User, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.UserStore.GetProfileByIds(ctx, userIds, options, allowFromCache)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("UserStore.GetProfileByIds", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerUserStore) GetProfiles(options *model.UserGetOptions) ([]*model.User, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.UserStore.GetProfiles(options)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("UserStore.GetProfiles", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerUserStore) GetProfilesByUsernames(usernames []string, viewRestrictions *model.ViewUsersRestrictions) ([]*model.User, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.UserStore.GetProfilesByUsernames(usernames, viewRestrictions)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("UserStore.GetProfilesByUsernames", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerUserStore) GetProfilesInChannel(options *model.UserGetOptions) ([]*model.User, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.UserStore.GetProfilesInChannel(options)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("UserStore.GetProfilesInChannel", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerUserStore) GetProfilesInChannelByStatus(options *model.UserGetOptions) ([]*model.User, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.UserStore.GetProfilesInChannelByStatus(options)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("UserStore.GetProfilesInChannelByStatus", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerUserStore) GetProfilesNotInChannel(teamId string, channelId string, groupConstrained bool, offset int, limit int, viewRestrictions *model.ViewUsersRestrictions) ([]*model.User, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.UserStore.GetProfilesNotInChannel(teamId, channelId, groupConstrained, offset, limit, viewRestrictions)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("UserStore.GetProfilesNotInChannel", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerUserStore) GetProfilesNotInTeam(teamID string, groupConstrained bool, offset int, limit int, viewRestrictions *model.ViewUsersRestrictions) ([]*model.User, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.UserStore.GetProfilesNotInTeam(teamID, groupConstrained, offset, limit, viewRestrictions)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("UserStore.GetProfilesNotInTeam", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerUserStore) GetProfilesWithoutTeam(options *model.UserGetOptions) ([]*model.User, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.UserStore.GetProfilesWithoutTeam(options)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("UserStore.GetProfilesWithoutTeam", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerUserStore) GetRecentlyActiveUsersForTeam(teamID string, offset int, limit int, viewRestrictions *model.ViewUsersRestrictions) ([]*model.User, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.UserStore.GetRecentlyActiveUsersForTeam(teamID, offset, limit, viewRestrictions)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("UserStore.GetRecentlyActiveUsersForTeam", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerUserStore) GetSystemAdminProfiles() (map[string]*model.User, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.UserStore.GetSystemAdminProfiles()
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("UserStore.GetSystemAdminProfiles", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerUserStore) GetTeamGroupUsers(teamID string) ([]*model.User, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.UserStore.GetTeamGroupUsers(teamID)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("UserStore.GetTeamGroupUsers", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerUserStore) GetUnreadCount(userId string) (int64, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.UserStore.GetUnreadCount(userId)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("UserStore.GetUnreadCount", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerUserStore) GetUnreadCountForChannel(userId string, channelID string) (int64, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.UserStore.GetUnreadCountForChannel(userId, channelID)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("UserStore.GetUnreadCountForChannel", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerUserStore) GetUsersBatchForIndexing(startTime int64, endTime int64, limit int) ([]*model.UserForIndexing, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.UserStore.GetUsersBatchForIndexing(startTime, endTime, limit)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("UserStore.GetUsersBatchForIndexing", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerUserStore) InferSystemInstallDate() (int64, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.UserStore.InferSystemInstallDate()
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("UserStore.InferSystemInstallDate", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerUserStore) InvalidateProfileCacheForUser(userId string) {
|
|
start := timemodule.Now()
|
|
|
|
s.UserStore.InvalidateProfileCacheForUser(userId)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if true {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("UserStore.InvalidateProfileCacheForUser", success, elapsed)
|
|
}
|
|
}
|
|
|
|
func (s *TimerLayerUserStore) InvalidateProfilesInChannelCache(channelID string) {
|
|
start := timemodule.Now()
|
|
|
|
s.UserStore.InvalidateProfilesInChannelCache(channelID)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if true {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("UserStore.InvalidateProfilesInChannelCache", success, elapsed)
|
|
}
|
|
}
|
|
|
|
func (s *TimerLayerUserStore) InvalidateProfilesInChannelCacheByUser(userId string) {
|
|
start := timemodule.Now()
|
|
|
|
s.UserStore.InvalidateProfilesInChannelCacheByUser(userId)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if true {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("UserStore.InvalidateProfilesInChannelCacheByUser", success, elapsed)
|
|
}
|
|
}
|
|
|
|
func (s *TimerLayerUserStore) PermanentDelete(userId string) error {
|
|
start := timemodule.Now()
|
|
|
|
err := s.UserStore.PermanentDelete(userId)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("UserStore.PermanentDelete", success, elapsed)
|
|
}
|
|
return err
|
|
}
|
|
|
|
func (s *TimerLayerUserStore) PromoteGuestToUser(userID string) error {
|
|
start := timemodule.Now()
|
|
|
|
err := s.UserStore.PromoteGuestToUser(userID)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("UserStore.PromoteGuestToUser", success, elapsed)
|
|
}
|
|
return err
|
|
}
|
|
|
|
func (s *TimerLayerUserStore) ResetLastPictureUpdate(userId string) error {
|
|
start := timemodule.Now()
|
|
|
|
err := s.UserStore.ResetLastPictureUpdate(userId)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("UserStore.ResetLastPictureUpdate", success, elapsed)
|
|
}
|
|
return err
|
|
}
|
|
|
|
func (s *TimerLayerUserStore) Save(user *model.User) (*model.User, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.UserStore.Save(user)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("UserStore.Save", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerUserStore) Search(teamID string, term string, options *model.UserSearchOptions) ([]*model.User, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.UserStore.Search(teamID, term, options)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("UserStore.Search", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerUserStore) SearchInChannel(channelID string, term string, options *model.UserSearchOptions) ([]*model.User, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.UserStore.SearchInChannel(channelID, term, options)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("UserStore.SearchInChannel", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerUserStore) SearchInGroup(groupID string, term string, options *model.UserSearchOptions) ([]*model.User, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.UserStore.SearchInGroup(groupID, term, options)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("UserStore.SearchInGroup", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerUserStore) SearchNotInChannel(teamID string, channelID string, term string, options *model.UserSearchOptions) ([]*model.User, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.UserStore.SearchNotInChannel(teamID, channelID, term, options)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("UserStore.SearchNotInChannel", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerUserStore) SearchNotInTeam(notInTeamId string, term string, options *model.UserSearchOptions) ([]*model.User, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.UserStore.SearchNotInTeam(notInTeamId, term, options)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("UserStore.SearchNotInTeam", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerUserStore) SearchWithoutTeam(term string, options *model.UserSearchOptions) ([]*model.User, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.UserStore.SearchWithoutTeam(term, options)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("UserStore.SearchWithoutTeam", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerUserStore) Update(user *model.User, allowRoleUpdate bool) (*model.UserUpdate, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.UserStore.Update(user, allowRoleUpdate)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("UserStore.Update", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerUserStore) UpdateAuthData(userId string, service string, authData *string, email string, resetMfa bool) (string, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.UserStore.UpdateAuthData(userId, service, authData, email, resetMfa)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("UserStore.UpdateAuthData", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerUserStore) UpdateFailedPasswordAttempts(userId string, attempts int) error {
|
|
start := timemodule.Now()
|
|
|
|
err := s.UserStore.UpdateFailedPasswordAttempts(userId, attempts)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("UserStore.UpdateFailedPasswordAttempts", success, elapsed)
|
|
}
|
|
return err
|
|
}
|
|
|
|
func (s *TimerLayerUserStore) UpdateLastPictureUpdate(userId string) error {
|
|
start := timemodule.Now()
|
|
|
|
err := s.UserStore.UpdateLastPictureUpdate(userId)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("UserStore.UpdateLastPictureUpdate", success, elapsed)
|
|
}
|
|
return err
|
|
}
|
|
|
|
func (s *TimerLayerUserStore) UpdateMfaActive(userId string, active bool) error {
|
|
start := timemodule.Now()
|
|
|
|
err := s.UserStore.UpdateMfaActive(userId, active)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("UserStore.UpdateMfaActive", success, elapsed)
|
|
}
|
|
return err
|
|
}
|
|
|
|
func (s *TimerLayerUserStore) UpdateMfaSecret(userId string, secret string) error {
|
|
start := timemodule.Now()
|
|
|
|
err := s.UserStore.UpdateMfaSecret(userId, secret)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("UserStore.UpdateMfaSecret", success, elapsed)
|
|
}
|
|
return err
|
|
}
|
|
|
|
func (s *TimerLayerUserStore) UpdatePassword(userId string, newPassword string) error {
|
|
start := timemodule.Now()
|
|
|
|
err := s.UserStore.UpdatePassword(userId, newPassword)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("UserStore.UpdatePassword", success, elapsed)
|
|
}
|
|
return err
|
|
}
|
|
|
|
func (s *TimerLayerUserStore) UpdateUpdateAt(userId string) (int64, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.UserStore.UpdateUpdateAt(userId)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("UserStore.UpdateUpdateAt", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerUserStore) VerifyEmail(userId string, email string) (string, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.UserStore.VerifyEmail(userId, email)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("UserStore.VerifyEmail", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerUserAccessTokenStore) Delete(tokenID string) error {
|
|
start := timemodule.Now()
|
|
|
|
err := s.UserAccessTokenStore.Delete(tokenID)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("UserAccessTokenStore.Delete", success, elapsed)
|
|
}
|
|
return err
|
|
}
|
|
|
|
func (s *TimerLayerUserAccessTokenStore) DeleteAllForUser(userId string) error {
|
|
start := timemodule.Now()
|
|
|
|
err := s.UserAccessTokenStore.DeleteAllForUser(userId)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("UserAccessTokenStore.DeleteAllForUser", success, elapsed)
|
|
}
|
|
return err
|
|
}
|
|
|
|
func (s *TimerLayerUserAccessTokenStore) Get(tokenID string) (*model.UserAccessToken, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.UserAccessTokenStore.Get(tokenID)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("UserAccessTokenStore.Get", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerUserAccessTokenStore) GetAll(offset int, limit int) ([]*model.UserAccessToken, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.UserAccessTokenStore.GetAll(offset, limit)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("UserAccessTokenStore.GetAll", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerUserAccessTokenStore) GetByToken(tokenString string) (*model.UserAccessToken, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.UserAccessTokenStore.GetByToken(tokenString)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("UserAccessTokenStore.GetByToken", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerUserAccessTokenStore) GetByUser(userId string, page int, perPage int) ([]*model.UserAccessToken, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.UserAccessTokenStore.GetByUser(userId, page, perPage)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("UserAccessTokenStore.GetByUser", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerUserAccessTokenStore) Save(token *model.UserAccessToken) (*model.UserAccessToken, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.UserAccessTokenStore.Save(token)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("UserAccessTokenStore.Save", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerUserAccessTokenStore) Search(term string) ([]*model.UserAccessToken, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.UserAccessTokenStore.Search(term)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("UserAccessTokenStore.Search", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerUserAccessTokenStore) UpdateTokenDisable(tokenID string) error {
|
|
start := timemodule.Now()
|
|
|
|
err := s.UserAccessTokenStore.UpdateTokenDisable(tokenID)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("UserAccessTokenStore.UpdateTokenDisable", success, elapsed)
|
|
}
|
|
return err
|
|
}
|
|
|
|
func (s *TimerLayerUserAccessTokenStore) UpdateTokenEnable(tokenID string) error {
|
|
start := timemodule.Now()
|
|
|
|
err := s.UserAccessTokenStore.UpdateTokenEnable(tokenID)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("UserAccessTokenStore.UpdateTokenEnable", success, elapsed)
|
|
}
|
|
return err
|
|
}
|
|
|
|
func (s *TimerLayerUserTermsOfServiceStore) Delete(userId string, termsOfServiceId string) error {
|
|
start := timemodule.Now()
|
|
|
|
err := s.UserTermsOfServiceStore.Delete(userId, termsOfServiceId)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("UserTermsOfServiceStore.Delete", success, elapsed)
|
|
}
|
|
return err
|
|
}
|
|
|
|
func (s *TimerLayerUserTermsOfServiceStore) GetByUser(userId string) (*model.UserTermsOfService, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.UserTermsOfServiceStore.GetByUser(userId)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("UserTermsOfServiceStore.GetByUser", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerUserTermsOfServiceStore) Save(userTermsOfService *model.UserTermsOfService) (*model.UserTermsOfService, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.UserTermsOfServiceStore.Save(userTermsOfService)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("UserTermsOfServiceStore.Save", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerWebhookStore) AnalyticsIncomingCount(teamID string) (int64, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.WebhookStore.AnalyticsIncomingCount(teamID)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("WebhookStore.AnalyticsIncomingCount", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerWebhookStore) AnalyticsOutgoingCount(teamID string) (int64, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.WebhookStore.AnalyticsOutgoingCount(teamID)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("WebhookStore.AnalyticsOutgoingCount", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerWebhookStore) ClearCaches() {
|
|
start := timemodule.Now()
|
|
|
|
s.WebhookStore.ClearCaches()
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if true {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("WebhookStore.ClearCaches", success, elapsed)
|
|
}
|
|
}
|
|
|
|
func (s *TimerLayerWebhookStore) DeleteIncoming(webhookID string, time int64) error {
|
|
start := timemodule.Now()
|
|
|
|
err := s.WebhookStore.DeleteIncoming(webhookID, time)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("WebhookStore.DeleteIncoming", success, elapsed)
|
|
}
|
|
return err
|
|
}
|
|
|
|
func (s *TimerLayerWebhookStore) DeleteOutgoing(webhookID string, time int64) error {
|
|
start := timemodule.Now()
|
|
|
|
err := s.WebhookStore.DeleteOutgoing(webhookID, time)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("WebhookStore.DeleteOutgoing", success, elapsed)
|
|
}
|
|
return err
|
|
}
|
|
|
|
func (s *TimerLayerWebhookStore) GetIncoming(id string, allowFromCache bool) (*model.IncomingWebhook, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.WebhookStore.GetIncoming(id, allowFromCache)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("WebhookStore.GetIncoming", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerWebhookStore) GetIncomingByChannel(channelID string) ([]*model.IncomingWebhook, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.WebhookStore.GetIncomingByChannel(channelID)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("WebhookStore.GetIncomingByChannel", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerWebhookStore) GetIncomingByTeam(teamID string, offset int, limit int) ([]*model.IncomingWebhook, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.WebhookStore.GetIncomingByTeam(teamID, offset, limit)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("WebhookStore.GetIncomingByTeam", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerWebhookStore) GetIncomingByTeamByUser(teamID string, userId string, offset int, limit int) ([]*model.IncomingWebhook, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.WebhookStore.GetIncomingByTeamByUser(teamID, userId, offset, limit)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("WebhookStore.GetIncomingByTeamByUser", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerWebhookStore) GetIncomingList(offset int, limit int) ([]*model.IncomingWebhook, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.WebhookStore.GetIncomingList(offset, limit)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("WebhookStore.GetIncomingList", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerWebhookStore) GetIncomingListByUser(userId string, offset int, limit int) ([]*model.IncomingWebhook, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.WebhookStore.GetIncomingListByUser(userId, offset, limit)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("WebhookStore.GetIncomingListByUser", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerWebhookStore) GetOutgoing(id string) (*model.OutgoingWebhook, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.WebhookStore.GetOutgoing(id)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("WebhookStore.GetOutgoing", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerWebhookStore) GetOutgoingByChannel(channelID string, offset int, limit int) ([]*model.OutgoingWebhook, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.WebhookStore.GetOutgoingByChannel(channelID, offset, limit)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("WebhookStore.GetOutgoingByChannel", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerWebhookStore) GetOutgoingByChannelByUser(channelID string, userId string, offset int, limit int) ([]*model.OutgoingWebhook, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.WebhookStore.GetOutgoingByChannelByUser(channelID, userId, offset, limit)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("WebhookStore.GetOutgoingByChannelByUser", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerWebhookStore) GetOutgoingByTeam(teamID string, offset int, limit int) ([]*model.OutgoingWebhook, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.WebhookStore.GetOutgoingByTeam(teamID, offset, limit)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("WebhookStore.GetOutgoingByTeam", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerWebhookStore) GetOutgoingByTeamByUser(teamID string, userId string, offset int, limit int) ([]*model.OutgoingWebhook, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.WebhookStore.GetOutgoingByTeamByUser(teamID, userId, offset, limit)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("WebhookStore.GetOutgoingByTeamByUser", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerWebhookStore) GetOutgoingList(offset int, limit int) ([]*model.OutgoingWebhook, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.WebhookStore.GetOutgoingList(offset, limit)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("WebhookStore.GetOutgoingList", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerWebhookStore) GetOutgoingListByUser(userId string, offset int, limit int) ([]*model.OutgoingWebhook, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.WebhookStore.GetOutgoingListByUser(userId, offset, limit)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("WebhookStore.GetOutgoingListByUser", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerWebhookStore) InvalidateWebhookCache(webhook string) {
|
|
start := timemodule.Now()
|
|
|
|
s.WebhookStore.InvalidateWebhookCache(webhook)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if true {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("WebhookStore.InvalidateWebhookCache", success, elapsed)
|
|
}
|
|
}
|
|
|
|
func (s *TimerLayerWebhookStore) PermanentDeleteIncomingByChannel(channelID string) error {
|
|
start := timemodule.Now()
|
|
|
|
err := s.WebhookStore.PermanentDeleteIncomingByChannel(channelID)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("WebhookStore.PermanentDeleteIncomingByChannel", success, elapsed)
|
|
}
|
|
return err
|
|
}
|
|
|
|
func (s *TimerLayerWebhookStore) PermanentDeleteIncomingByUser(userId string) error {
|
|
start := timemodule.Now()
|
|
|
|
err := s.WebhookStore.PermanentDeleteIncomingByUser(userId)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("WebhookStore.PermanentDeleteIncomingByUser", success, elapsed)
|
|
}
|
|
return err
|
|
}
|
|
|
|
func (s *TimerLayerWebhookStore) PermanentDeleteOutgoingByChannel(channelID string) error {
|
|
start := timemodule.Now()
|
|
|
|
err := s.WebhookStore.PermanentDeleteOutgoingByChannel(channelID)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("WebhookStore.PermanentDeleteOutgoingByChannel", success, elapsed)
|
|
}
|
|
return err
|
|
}
|
|
|
|
func (s *TimerLayerWebhookStore) PermanentDeleteOutgoingByUser(userId string) error {
|
|
start := timemodule.Now()
|
|
|
|
err := s.WebhookStore.PermanentDeleteOutgoingByUser(userId)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("WebhookStore.PermanentDeleteOutgoingByUser", success, elapsed)
|
|
}
|
|
return err
|
|
}
|
|
|
|
func (s *TimerLayerWebhookStore) SaveIncoming(webhook *model.IncomingWebhook) (*model.IncomingWebhook, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.WebhookStore.SaveIncoming(webhook)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("WebhookStore.SaveIncoming", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerWebhookStore) SaveOutgoing(webhook *model.OutgoingWebhook) (*model.OutgoingWebhook, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.WebhookStore.SaveOutgoing(webhook)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("WebhookStore.SaveOutgoing", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerWebhookStore) UpdateIncoming(webhook *model.IncomingWebhook) (*model.IncomingWebhook, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.WebhookStore.UpdateIncoming(webhook)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("WebhookStore.UpdateIncoming", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayerWebhookStore) UpdateOutgoing(hook *model.OutgoingWebhook) (*model.OutgoingWebhook, error) {
|
|
start := timemodule.Now()
|
|
|
|
result, err := s.WebhookStore.UpdateOutgoing(hook)
|
|
|
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
|
if s.Root.Metrics != nil {
|
|
success := "false"
|
|
if err == nil {
|
|
success = "true"
|
|
}
|
|
s.Root.Metrics.ObserveStoreMethodDuration("WebhookStore.UpdateOutgoing", success, elapsed)
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
func (s *TimerLayer) Close() {
|
|
s.Store.Close()
|
|
}
|
|
|
|
func (s *TimerLayer) DropAllTables() {
|
|
s.Store.DropAllTables()
|
|
}
|
|
|
|
func (s *TimerLayer) GetCurrentSchemaVersion() string {
|
|
return s.Store.GetCurrentSchemaVersion()
|
|
}
|
|
|
|
func (s *TimerLayer) LockToMaster() {
|
|
s.Store.LockToMaster()
|
|
}
|
|
|
|
func (s *TimerLayer) MarkSystemRanUnitTests() {
|
|
s.Store.MarkSystemRanUnitTests()
|
|
}
|
|
|
|
func (s *TimerLayer) SetContext(context context.Context) {
|
|
s.Store.SetContext(context)
|
|
}
|
|
|
|
func (s *TimerLayer) TotalMasterDbConnections() int {
|
|
return s.Store.TotalMasterDbConnections()
|
|
}
|
|
|
|
func (s *TimerLayer) TotalReadDbConnections() int {
|
|
return s.Store.TotalReadDbConnections()
|
|
}
|
|
|
|
func (s *TimerLayer) TotalSearchDbConnections() int {
|
|
return s.Store.TotalSearchDbConnections()
|
|
}
|
|
|
|
func (s *TimerLayer) UnlockFromMaster() {
|
|
s.Store.UnlockFromMaster()
|
|
}
|
|
|
|
func New(childStore store.Store, metrics einterfaces.MetricsInterface) *TimerLayer {
|
|
newStore := TimerLayer{
|
|
Store: childStore,
|
|
Metrics: metrics,
|
|
}
|
|
|
|
newStore.AuditStore = &TimerLayerAuditStore{AuditStore: childStore.Audit(), Root: &newStore}
|
|
newStore.BotStore = &TimerLayerBotStore{BotStore: childStore.Bot(), Root: &newStore}
|
|
newStore.ChannelStore = &TimerLayerChannelStore{ChannelStore: childStore.Channel(), Root: &newStore}
|
|
newStore.ChannelMemberHistoryStore = &TimerLayerChannelMemberHistoryStore{ChannelMemberHistoryStore: childStore.ChannelMemberHistory(), Root: &newStore}
|
|
newStore.ClusterDiscoveryStore = &TimerLayerClusterDiscoveryStore{ClusterDiscoveryStore: childStore.ClusterDiscovery(), Root: &newStore}
|
|
newStore.CommandStore = &TimerLayerCommandStore{CommandStore: childStore.Command(), Root: &newStore}
|
|
newStore.CommandWebhookStore = &TimerLayerCommandWebhookStore{CommandWebhookStore: childStore.CommandWebhook(), Root: &newStore}
|
|
newStore.ComplianceStore = &TimerLayerComplianceStore{ComplianceStore: childStore.Compliance(), Root: &newStore}
|
|
newStore.EmojiStore = &TimerLayerEmojiStore{EmojiStore: childStore.Emoji(), Root: &newStore}
|
|
newStore.FileInfoStore = &TimerLayerFileInfoStore{FileInfoStore: childStore.FileInfo(), Root: &newStore}
|
|
newStore.GroupStore = &TimerLayerGroupStore{GroupStore: childStore.Group(), Root: &newStore}
|
|
newStore.JobStore = &TimerLayerJobStore{JobStore: childStore.Job(), Root: &newStore}
|
|
newStore.LicenseStore = &TimerLayerLicenseStore{LicenseStore: childStore.License(), Root: &newStore}
|
|
newStore.LinkMetadataStore = &TimerLayerLinkMetadataStore{LinkMetadataStore: childStore.LinkMetadata(), Root: &newStore}
|
|
newStore.OAuthStore = &TimerLayerOAuthStore{OAuthStore: childStore.OAuth(), Root: &newStore}
|
|
newStore.PluginStore = &TimerLayerPluginStore{PluginStore: childStore.Plugin(), Root: &newStore}
|
|
newStore.PostStore = &TimerLayerPostStore{PostStore: childStore.Post(), Root: &newStore}
|
|
newStore.PreferenceStore = &TimerLayerPreferenceStore{PreferenceStore: childStore.Preference(), Root: &newStore}
|
|
newStore.ProductNoticesStore = &TimerLayerProductNoticesStore{ProductNoticesStore: childStore.ProductNotices(), Root: &newStore}
|
|
newStore.ReactionStore = &TimerLayerReactionStore{ReactionStore: childStore.Reaction(), Root: &newStore}
|
|
newStore.RoleStore = &TimerLayerRoleStore{RoleStore: childStore.Role(), Root: &newStore}
|
|
newStore.SchemeStore = &TimerLayerSchemeStore{SchemeStore: childStore.Scheme(), Root: &newStore}
|
|
newStore.SessionStore = &TimerLayerSessionStore{SessionStore: childStore.Session(), Root: &newStore}
|
|
newStore.StatusStore = &TimerLayerStatusStore{StatusStore: childStore.Status(), Root: &newStore}
|
|
newStore.SystemStore = &TimerLayerSystemStore{SystemStore: childStore.System(), Root: &newStore}
|
|
newStore.TeamStore = &TimerLayerTeamStore{TeamStore: childStore.Team(), Root: &newStore}
|
|
newStore.TermsOfServiceStore = &TimerLayerTermsOfServiceStore{TermsOfServiceStore: childStore.TermsOfService(), Root: &newStore}
|
|
newStore.ThreadStore = &TimerLayerThreadStore{ThreadStore: childStore.Thread(), Root: &newStore}
|
|
newStore.TokenStore = &TimerLayerTokenStore{TokenStore: childStore.Token(), Root: &newStore}
|
|
newStore.UploadSessionStore = &TimerLayerUploadSessionStore{UploadSessionStore: childStore.UploadSession(), Root: &newStore}
|
|
newStore.UserStore = &TimerLayerUserStore{UserStore: childStore.User(), Root: &newStore}
|
|
newStore.UserAccessTokenStore = &TimerLayerUserAccessTokenStore{UserAccessTokenStore: childStore.UserAccessToken(), Root: &newStore}
|
|
newStore.UserTermsOfServiceStore = &TimerLayerUserTermsOfServiceStore{UserTermsOfServiceStore: childStore.UserTermsOfService(), Root: &newStore}
|
|
newStore.WebhookStore = &TimerLayerWebhookStore{WebhookStore: childStore.Webhook(), Root: &newStore}
|
|
return &newStore
|
|
}
|