diff --git a/.circleci/config.yml b/.circleci/config.yml index a1e2b2f67f..bff65d5d36 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -52,7 +52,7 @@ jobs: build: docker: - - image: mattermost/mattermost-build-server:feb-28-2019 + - image: mattermost/mattermost-build-server:sep-17-2019 working_directory: /go/src/github.com/mattermost steps: - attach_workspace: @@ -119,7 +119,7 @@ jobs: --env MM_ELASTICSEARCHSETTINGS_CONNECTIONURL=http://elasticsearch:9200 \ -v ~/go/src:/go/src \ -w /go/src/github.com/mattermost/mattermost-server \ - mattermost/mattermost-build-server:feb-28-2019 \ + mattermost/mattermost-build-server:sep-17-2019 \ bash -c 'ulimit -n 8096; make test-server BUILD_NUMBER="$CIRCLE_BRANCH-$CIRCLE_PREVIOUS_BUILD_NUM" TESTFLAGS= TESTFLAGSEE=' no_output_timeout: 1h - run: diff --git a/Makefile b/Makefile index d76f4ff3af..4cedf9b666 100644 --- a/Makefile +++ b/Makefile @@ -45,8 +45,9 @@ else endif # Golang Flags +export GO111MODULE=on GOPATH ?= $(shell go env GOPATH) -GOFLAGS ?= $(GOFLAGS:) +GOFLAGS ?= $(GOFLAGS:) -mod=vendor GO=go DELVE=dlv LDFLAGS += -X "github.com/mattermost/mattermost-server/model.BuildNumber=$(BUILD_NUMBER)" @@ -141,7 +142,7 @@ clean-docker: ## Deletes the docker containers for local development. govet: ## Runs govet against all packages. @echo Running GOVET - $(GO) get golang.org/x/tools/go/analysis/passes/shadow/cmd/shadow + env GO111MODULE=off $(GO) get golang.org/x/tools/go/analysis/passes/shadow/cmd/shadow $(GO) vet $(GOFLAGS) $(ALL_PACKAGES) || exit 1 $(GO) vet -vettool=$(GOPATH)/bin/shadow $(GOFLAGS) $(ALL_PACKAGES) || exit 1 $(GO) run plugin/checker/main.go @@ -151,7 +152,7 @@ gofmt: ## Runs gofmt against all packages. @for package in $(TE_PACKAGES) $(EE_PACKAGES); do \ echo "Checking "$$package; \ - files=$$(go list -f '{{range .GoFiles}}{{$$.Dir}}/{{.}} {{end}}' $$package); \ + files=$$($(GO) list $(GOFLAGS) -f '{{range .GoFiles}}{{$$.Dir}}/{{.}} {{end}}' $$package); \ if [ "$$files" ]; then \ gofmt_output=$$(gofmt -d -s $$files 2>&1); \ if [ "$$gofmt_output" ]; then \ @@ -180,7 +181,7 @@ store-mocks: ## Creates mock files. $(GOPATH)/bin/mockery -dir store -all -output store/storetest/mocks -note 'Regenerate this file using `make store-mocks`.' store-layers: ## Generate layers for the store - go generate ./store + $(GO) generate $(GOFLAGS) ./store filesstore-mocks: ## Creates mock files. env GO111MODULE=off go get -u github.com/vektra/mockery/... @@ -201,7 +202,7 @@ einterfaces-mocks: ## Creates mock files for einterfaces. $(GOPATH)/bin/mockery -dir einterfaces -all -output einterfaces/mocks -note 'Regenerate this file using `make einterfaces-mocks`.' pluginapi: ## Generates api and hooks glue code for plugins - go generate ./plugin + $(GO) generate $(GOFLAGS) ./plugin check-licenses: ## Checks license status. ./scripts/license-check.sh $(TE_PACKAGES) $(EE_PACKAGES) @@ -409,7 +410,7 @@ config-ldap: ## Configures LDAP. config-reset: ## Resets the config/config.json file to the default. @echo Resetting configuration to default rm -f config/config.json - OUTPUT_CONFIG=$(PWD)/config/config.json go generate ./config + OUTPUT_CONFIG=$(PWD)/config/config.json $(GO) generate $(GOFLAGS) ./config diff-config: ## Compares default configuration between two mattermost versions @./scripts/diff-config.sh diff --git a/app/channel_test.go b/app/channel_test.go index 3bc394b1db..49a0f15fa8 100644 --- a/app/channel_test.go +++ b/app/channel_test.go @@ -25,22 +25,20 @@ func TestPermanentDeleteChannel(t *testing.T) { }) channel, err := th.App.CreateChannel(&model.Channel{DisplayName: "deletion-test", Name: "deletion-test", Type: model.CHANNEL_OPEN, TeamId: th.BasicTeam.Id}, false) - if err != nil { - t.Fatal(err.Error()) - } + require.NotNil(t, channel, "Channel shouldn't be nil") + require.Nil(t, err) defer func() { th.App.PermanentDeleteChannel(channel) }() incoming, err := th.App.CreateIncomingWebhookForChannel(th.BasicUser.Id, channel, &model.IncomingWebhook{ChannelId: channel.Id}) - if err != nil { - t.Fatal(err.Error()) - } + require.NotNil(t, incoming, "incoming webhook should not be nil") + require.Nil(t, err, "Unable to create Incoming Webhook for Channel") defer th.App.DeleteIncomingWebhook(incoming.Id) - if incoming, err = th.App.GetIncomingWebhook(incoming.Id); incoming == nil || err != nil { - t.Fatal("unable to get new incoming webhook") - } + incoming, err = th.App.GetIncomingWebhook(incoming.Id) + require.NotNil(t, incoming, "incoming webhook should not be nil") + require.Nil(t, err, "Unable to get new incoming webhook") outgoing, err := th.App.CreateOutgoingWebhook(&model.OutgoingWebhook{ ChannelId: channel.Id, @@ -48,30 +46,29 @@ func TestPermanentDeleteChannel(t *testing.T) { CreatorId: th.BasicUser.Id, CallbackURLs: []string{"http://foo"}, }) - if err != nil { - t.Fatal(err.Error()) - } + require.Nil(t, err) defer th.App.DeleteOutgoingWebhook(outgoing.Id) - if outgoing, err = th.App.GetOutgoingWebhook(outgoing.Id); outgoing == nil || err != nil { - t.Fatal("unable to get new outgoing webhook") - } + outgoing, err = th.App.GetOutgoingWebhook(outgoing.Id) + require.NotNil(t, outgoing, "Outgoing webhook should not be nil") + require.Nil(t, err, "Unable to get new outgoing webhook") err = th.App.PermanentDeleteChannel(channel) require.Nil(t, err) - if incoming, err = th.App.GetIncomingWebhook(incoming.Id); incoming != nil || err == nil { - t.Error("incoming webhook wasn't deleted") - } + incoming, err = th.App.GetIncomingWebhook(incoming.Id) + require.Nil(t, incoming, "Incoming webhook should be nil") + require.NotNil(t, err, "Incoming webhook wasn't deleted") - if outgoing, err = th.App.GetOutgoingWebhook(outgoing.Id); outgoing != nil || err == nil { - t.Error("outgoing webhook wasn't deleted") - } + outgoing, err = th.App.GetOutgoingWebhook(outgoing.Id) + require.Nil(t, outgoing, "Outgoing webhook should be nil") + require.NotNil(t, err, "Outgoing webhook wasn't deleted") } func TestMoveChannel(t *testing.T) { th := Setup(t).InitBasic() defer th.TearDown() + var err *model.AppError sourceTeam := th.CreateTeam() targetTeam := th.CreateTeam() @@ -82,62 +79,51 @@ func TestMoveChannel(t *testing.T) { th.App.PermanentDeleteTeam(targetTeam) }() - if _, err := th.App.AddUserToTeam(sourceTeam.Id, th.BasicUser.Id, ""); err != nil { - t.Fatal(err) - } - if _, err := th.App.AddUserToTeam(sourceTeam.Id, th.BasicUser2.Id, ""); err != nil { - t.Fatal(err) - } + _, err = th.App.AddUserToTeam(sourceTeam.Id, th.BasicUser.Id, "") + require.Nil(t, err) - if _, err := th.App.AddUserToTeam(targetTeam.Id, th.BasicUser.Id, ""); err != nil { - t.Fatal(err) - } + _, err = th.App.AddUserToTeam(sourceTeam.Id, th.BasicUser2.Id, "") + require.Nil(t, err) - if _, err := th.App.AddUserToChannel(th.BasicUser, channel1); err != nil { - t.Fatal(err) - } - if _, err := th.App.AddUserToChannel(th.BasicUser2, channel1); err != nil { - t.Fatal(err) - } + _, err = th.App.AddUserToTeam(targetTeam.Id, th.BasicUser.Id, "") + require.Nil(t, err) - if err := th.App.MoveChannel(targetTeam, channel1, th.BasicUser, false); err == nil { - t.Fatal("Should have failed due to mismatched members.") - } + _, err = th.App.AddUserToChannel(th.BasicUser, channel1) + require.Nil(t, err) - if _, err := th.App.AddUserToTeam(targetTeam.Id, th.BasicUser2.Id, ""); err != nil { - t.Fatal(err) - } + _, err = th.App.AddUserToChannel(th.BasicUser2, channel1) + require.Nil(t, err) - if err := th.App.MoveChannel(targetTeam, channel1, th.BasicUser, false); err != nil { - t.Fatal(err) - } + err = th.App.MoveChannel(targetTeam, channel1, th.BasicUser, false) + require.NotNil(t, err, "Should have failed due to mismatched members.") + + _, err = th.App.AddUserToTeam(targetTeam.Id, th.BasicUser2.Id, "") + require.Nil(t, err) + + err = th.App.MoveChannel(targetTeam, channel1, th.BasicUser, false) + require.Nil(t, err) // Test moving a channel with a deactivated user who isn't in the destination team. // It should fail, unless removeDeactivatedMembers is true. deacivatedUser := th.CreateUser() channel2 := th.CreateChannel(sourceTeam) - if _, err := th.App.AddUserToTeam(sourceTeam.Id, deacivatedUser.Id, ""); err != nil { - t.Fatal(err) - } - if _, err := th.App.AddUserToChannel(th.BasicUser, channel2); err != nil { - t.Fatal(err) - } - if _, err := th.App.AddUserToChannel(deacivatedUser, channel2); err != nil { - t.Fatal(err) - } + _, err = th.App.AddUserToTeam(sourceTeam.Id, deacivatedUser.Id, "") + require.Nil(t, err) + _, err = th.App.AddUserToChannel(th.BasicUser, channel2) + require.Nil(t, err) - if _, err := th.App.UpdateActive(deacivatedUser, false); err != nil { - t.Fatal(err) - } + _, err = th.App.AddUserToChannel(deacivatedUser, channel2) + require.Nil(t, err) - if err := th.App.MoveChannel(targetTeam, channel2, th.BasicUser, false); err == nil { - t.Fatal("Should have failed due to mismatched deacivated member.") - } + _, err = th.App.UpdateActive(deacivatedUser, false) + require.Nil(t, err) - if err := th.App.MoveChannel(targetTeam, channel2, th.BasicUser, true); err != nil { - t.Fatal(err) - } + err = th.App.MoveChannel(targetTeam, channel2, th.BasicUser, false) + require.NotNil(t, err, "Should have failed due to mismatched deacivated member.") + + err = th.App.MoveChannel(targetTeam, channel2, th.BasicUser, true) + require.Nil(t, err) // Test moving a channel with no members. channel3 := &model.Channel{ @@ -148,7 +134,6 @@ func TestMoveChannel(t *testing.T) { CreatorId: th.BasicUser.Id, } - var err *model.AppError channel3, err = th.App.CreateChannel(channel3, false) require.Nil(t, err) @@ -231,20 +216,12 @@ func TestJoinDefaultChannelsExperimentalDefaultChannels(t *testing.T) { for _, channelName := range defaultChannelList { channel, err := th.App.GetChannelByName(channelName, th.BasicTeam.Id, false) - - if err != nil { - t.Errorf("Expected nil, got %s", err) - } + require.Nil(t, err, "Expected nil, didn't receive nil") member, err := th.App.GetChannelMember(channel.Id, user.Id) - if member == nil { - t.Errorf("Expected member object, got nil") - } - - if err != nil { - t.Errorf("Expected nil object, got %s", err) - } + require.NotNil(t, member, "Expected member object, got nil") + require.Nil(t, err, "Expected nil object, didn't receive nil") } } @@ -285,12 +262,10 @@ func TestUpdateChannelPrivacy(t *testing.T) { privateChannel := th.createChannel(th.BasicTeam, model.CHANNEL_PRIVATE) privateChannel.Type = model.CHANNEL_OPEN - if publicChannel, err := th.App.UpdateChannelPrivacy(privateChannel, th.BasicUser); err != nil { - t.Fatal("Failed to update channel privacy. Error: " + err.Error()) - } else { - assert.Equal(t, publicChannel.Id, privateChannel.Id) - assert.Equal(t, publicChannel.Type, model.CHANNEL_OPEN) - } + publicChannel, err := th.App.UpdateChannelPrivacy(privateChannel, th.BasicUser) + require.Nil(t, err, "Failed to update channel privacy.") + assert.Equal(t, publicChannel.Id, privateChannel.Id) + assert.Equal(t, publicChannel.Type, model.CHANNEL_OPEN) } func TestCreateGroupChannelCreatesChannelMemberHistoryRecord(t *testing.T) { @@ -305,24 +280,22 @@ func TestCreateGroupChannelCreatesChannelMemberHistoryRecord(t *testing.T) { groupUserIds = append(groupUserIds, user2.Id) groupUserIds = append(groupUserIds, th.BasicUser.Id) - if channel, err := th.App.CreateGroupChannel(groupUserIds, th.BasicUser.Id); err != nil { - t.Fatal("Failed to create group channel. Error: " + err.Message) - } else { - // there should be a ChannelMemberHistory record for each user - histories, err := th.App.Srv.Store.ChannelMemberHistory().GetUsersInChannelDuring(model.GetMillis()-100, model.GetMillis()+100, channel.Id) - require.Nil(t, err) - assert.Len(t, histories, 3) + channel, err := th.App.CreateGroupChannel(groupUserIds, th.BasicUser.Id) - channelMemberHistoryUserIds := make([]string, 0) - for _, history := range histories { - assert.Equal(t, channel.Id, history.ChannelId) - channelMemberHistoryUserIds = append(channelMemberHistoryUserIds, history.UserId) - } + require.Nil(t, err, "Failed to create group channel.") + histories, err := th.App.Srv.Store.ChannelMemberHistory().GetUsersInChannelDuring(model.GetMillis()-100, model.GetMillis()+100, channel.Id) + require.Nil(t, err) + assert.Len(t, histories, 3) - sort.Strings(groupUserIds) - sort.Strings(channelMemberHistoryUserIds) - assert.Equal(t, groupUserIds, channelMemberHistoryUserIds) + channelMemberHistoryUserIds := make([]string, 0) + for _, history := range histories { + assert.Equal(t, channel.Id, history.ChannelId) + channelMemberHistoryUserIds = append(channelMemberHistoryUserIds, history.UserId) } + + sort.Strings(groupUserIds) + sort.Strings(channelMemberHistoryUserIds) + assert.Equal(t, groupUserIds, channelMemberHistoryUserIds) } func TestCreateDirectChannelCreatesChannelMemberHistoryRecord(t *testing.T) { @@ -332,24 +305,22 @@ func TestCreateDirectChannelCreatesChannelMemberHistoryRecord(t *testing.T) { user1 := th.CreateUser() user2 := th.CreateUser() - if channel, err := th.App.GetOrCreateDirectChannel(user1.Id, user2.Id); err != nil { - t.Fatal("Failed to create direct channel. Error: " + err.Message) - } else { - // there should be a ChannelMemberHistory record for both users - histories, err := th.App.Srv.Store.ChannelMemberHistory().GetUsersInChannelDuring(model.GetMillis()-100, model.GetMillis()+100, channel.Id) - require.Nil(t, err) - assert.Len(t, histories, 2) + channel, err := th.App.GetOrCreateDirectChannel(user1.Id, user2.Id) + require.Nil(t, err, "Failed to create direct channel.") - historyId0 := histories[0].UserId - historyId1 := histories[1].UserId - switch historyId0 { - case user1.Id: - assert.Equal(t, user2.Id, historyId1) - case user2.Id: - assert.Equal(t, user1.Id, historyId1) - default: - t.Fatal("Unexpected user id " + historyId0 + " in ChannelMemberHistory table") - } + histories, err := th.App.Srv.Store.ChannelMemberHistory().GetUsersInChannelDuring(model.GetMillis()-100, model.GetMillis()+100, channel.Id) + require.Nil(t, err) + assert.Len(t, histories, 2) + + historyId0 := histories[0].UserId + historyId1 := histories[1].UserId + switch historyId0 { + case user1.Id: + assert.Equal(t, user2.Id, historyId1) + case user2.Id: + assert.Equal(t, user1.Id, historyId1) + default: + require.Fail(t, "Unexpected user id in ChannelMemberHistory table", historyId0) } } @@ -361,24 +332,23 @@ func TestGetDirectChannelCreatesChannelMemberHistoryRecord(t *testing.T) { user2 := th.CreateUser() // this function call implicitly creates a direct channel between the two users if one doesn't already exist - if channel, err := th.App.GetOrCreateDirectChannel(user1.Id, user2.Id); err != nil { - t.Fatal("Failed to create direct channel. Error: " + err.Message) - } else { - // there should be a ChannelMemberHistory record for both users - histories, err := th.App.Srv.Store.ChannelMemberHistory().GetUsersInChannelDuring(model.GetMillis()-100, model.GetMillis()+100, channel.Id) - require.Nil(t, err) - assert.Len(t, histories, 2) + channel, err := th.App.GetOrCreateDirectChannel(user1.Id, user2.Id) + require.Nil(t, err, "Failed to create direct channel.") - historyId0 := histories[0].UserId - historyId1 := histories[1].UserId - switch historyId0 { - case user1.Id: - assert.Equal(t, user2.Id, historyId1) - case user2.Id: - assert.Equal(t, user1.Id, historyId1) - default: - t.Fatal("Unexpected user id " + historyId0 + " in ChannelMemberHistory table") - } + // there should be a ChannelMemberHistory record for both users + histories, err := th.App.Srv.Store.ChannelMemberHistory().GetUsersInChannelDuring(model.GetMillis()-100, model.GetMillis()+100, channel.Id) + require.Nil(t, err) + assert.Len(t, histories, 2) + + historyId0 := histories[0].UserId + historyId1 := histories[1].UserId + switch historyId0 { + case user1.Id: + assert.Equal(t, user2.Id, historyId1) + case user2.Id: + assert.Equal(t, user1.Id, historyId1) + default: + require.Fail(t, "Unexpected user id in ChannelMemberHistory table", historyId0) } } @@ -388,18 +358,17 @@ func TestAddUserToChannelCreatesChannelMemberHistoryRecord(t *testing.T) { // create a user and add it to a channel user := th.CreateUser() - if _, err := th.App.AddTeamMember(th.BasicTeam.Id, user.Id); err != nil { - t.Fatal("Failed to add user to team. Error: " + err.Message) - } + _, err := th.App.AddTeamMember(th.BasicTeam.Id, user.Id) + require.Nil(t, err, "Failed to add user to team.") groupUserIds := make([]string, 0) groupUserIds = append(groupUserIds, th.BasicUser.Id) groupUserIds = append(groupUserIds, user.Id) channel := th.createChannel(th.BasicTeam, model.CHANNEL_OPEN) - if _, err := th.App.AddUserToChannel(user, channel); err != nil { - t.Fatal("Failed to add user to channel. Error: " + err.Message) - } + + _, err = th.App.AddUserToChannel(user, channel) + require.Nil(t, err, "Failed to add user to channel.") // there should be a ChannelMemberHistory record for the user histories, err := th.App.Srv.Store.ChannelMemberHistory().GetUsersInChannelDuring(model.GetMillis()-100, model.GetMillis()+100, channel.Id) @@ -511,9 +480,8 @@ func TestAddChannelMemberNoUserRequestor(t *testing.T) { channel := th.createChannel(th.BasicTeam, model.CHANNEL_OPEN) userRequestorId := "" postRootId := "" - if _, err := th.App.AddChannelMember(user.Id, channel, userRequestorId, postRootId); err != nil { - t.Fatal("Failed to add user to channel. Error: " + err.Message) - } + _, err := th.App.AddChannelMember(user.Id, channel, userRequestorId, postRootId) + require.Nil(t, err, "Failed to add user to channel.") // there should be a ChannelMemberHistory record for the user histories, err := th.App.Srv.Store.ChannelMemberHistory().GetUsersInChannelDuring(model.GetMillis()-100, model.GetMillis()+100, channel.Id) @@ -547,12 +515,10 @@ func TestAppUpdateChannelScheme(t *testing.T) { channel.SchemeId = mockID updatedChannel, err := th.App.UpdateChannelScheme(channel) - if err != nil { - t.Fatal(err) - } + require.Nil(t, err) if updatedChannel.SchemeId != mockID { - t.Fatal("Wrong Channel SchemeId") + require.Fail(t, "Wrong Channel SchemeId") } } @@ -814,9 +780,8 @@ func TestGetChannelMembersTimezones(t *testing.T) { userRequestorId := "" postRootId := "" - if _, err := th.App.AddChannelMember(th.BasicUser2.Id, th.BasicChannel, userRequestorId, postRootId); err != nil { - t.Fatal("Failed to add user to channel. Error: " + err.Message) - } + _, err := th.App.AddChannelMember(th.BasicUser2.Id, th.BasicChannel, userRequestorId, postRootId) + require.Nil(t, err, "Failed to add user to channel.") user := th.BasicUser user.Timezone["useAutomaticTimezone"] = "false" @@ -839,9 +804,8 @@ func TestGetChannelMembersTimezones(t *testing.T) { th.App.AddUserToChannel(ruser, th.BasicChannel) timezones, err := th.App.GetChannelMembersTimezones(th.BasicChannel.Id) - if err != nil { - t.Fatal("Failed to get the timezones for a channel. Error: " + err.Error()) - } + require.Nil(t, err, "Failed to get the timezones for a channel.") + assert.Equal(t, 2, len(timezones)) } @@ -903,9 +867,8 @@ func TestUpdateChannelMemberRolesChangingGuest(t *testing.T) { _, err = th.App.AddUserToChannel(ruser, th.BasicChannel) require.Nil(t, err) - if _, err := th.App.UpdateChannelMemberRoles(th.BasicChannel.Id, ruser.Id, "channel_user"); err == nil { - t.Fatal("Should fail when try to modify the guest role") - } + _, err = th.App.UpdateChannelMemberRoles(th.BasicChannel.Id, ruser.Id, "channel_user") + require.NotNil(t, err, "Should fail when try to modify the guest role") }) t.Run("from user to guest", func(t *testing.T) { @@ -918,9 +881,8 @@ func TestUpdateChannelMemberRolesChangingGuest(t *testing.T) { _, err = th.App.AddUserToChannel(ruser, th.BasicChannel) require.Nil(t, err) - if _, err := th.App.UpdateChannelMemberRoles(th.BasicChannel.Id, ruser.Id, "channel_guest"); err == nil { - t.Fatal("Should fail when try to modify the guest role") - } + _, err = th.App.UpdateChannelMemberRoles(th.BasicChannel.Id, ruser.Id, "channel_guest") + require.NotNil(t, err, "Should fail when try to modify the guest role") }) t.Run("from user to admin", func(t *testing.T) { @@ -933,9 +895,8 @@ func TestUpdateChannelMemberRolesChangingGuest(t *testing.T) { _, err = th.App.AddUserToChannel(ruser, th.BasicChannel) require.Nil(t, err) - if _, err := th.App.UpdateChannelMemberRoles(th.BasicChannel.Id, ruser.Id, "channel_user channel_admin"); err != nil { - t.Fatal("Should work when you not modify guest role") - } + _, err = th.App.UpdateChannelMemberRoles(th.BasicChannel.Id, ruser.Id, "channel_user channel_admin") + require.Nil(t, err, "Should work when you not modify guest role") }) t.Run("from guest to guest plus custom", func(t *testing.T) { @@ -951,9 +912,8 @@ func TestUpdateChannelMemberRolesChangingGuest(t *testing.T) { _, err = th.App.CreateRole(&model.Role{Name: "custom", DisplayName: "custom", Description: "custom"}) require.Nil(t, err) - if _, err := th.App.UpdateChannelMemberRoles(th.BasicChannel.Id, ruser.Id, "channel_guest custom"); err != nil { - t.Fatal("Should work when you not modify guest role") - } + _, err = th.App.UpdateChannelMemberRoles(th.BasicChannel.Id, ruser.Id, "channel_guest custom") + require.Nil(t, err, "Should work when you not modify guest role") }) t.Run("a guest cant have user role", func(t *testing.T) { @@ -966,9 +926,8 @@ func TestUpdateChannelMemberRolesChangingGuest(t *testing.T) { _, err = th.App.AddUserToChannel(ruser, th.BasicChannel) require.Nil(t, err) - if _, err := th.App.UpdateChannelMemberRoles(th.BasicChannel.Id, ruser.Id, "channel_guest channel_user"); err == nil { - t.Fatal("Should work when you not modify guest role") - } + _, err = th.App.UpdateChannelMemberRoles(th.BasicChannel.Id, ruser.Id, "channel_guest channel_user") + require.NotNil(t, err, "Should work when you not modify guest role") }) } diff --git a/app/command.go b/app/command.go index 0d44b5dd1c..c7f83c5b1e 100644 --- a/app/command.go +++ b/app/command.go @@ -158,7 +158,7 @@ func (a *App) ExecuteCommand(args *model.CommandArgs) (*model.CommandResponse, * clientTriggerId, triggerId, appErr := model.GenerateTriggerId(args.UserId, a.AsymmetricSigningKey()) if appErr != nil { - mlog.Error(appErr.Error()) + mlog.Error("error occurred in generating trigger Id for a user ", mlog.Err(appErr)) } args.TriggerId = triggerId @@ -362,7 +362,7 @@ func (a *App) HandleCommandResponse(command *model.Command, args *model.CommandA _, err := a.HandleCommandResponsePost(command, args, response, builtIn) if err != nil { - mlog.Error(err.Error()) + mlog.Error("error occurred in handling command response post", mlog.Err(err)) lastError = err } @@ -371,7 +371,7 @@ func (a *App) HandleCommandResponse(command *model.Command, args *model.CommandA _, err := a.HandleCommandResponsePost(command, args, resp, builtIn) if err != nil { - mlog.Error(err.Error()) + mlog.Error("error occurred in handling command response post", mlog.Err(err)) lastError = err } } diff --git a/app/command_groupmsg_test.go b/app/command_groupmsg_test.go index 5de4017058..6f0b702204 100644 --- a/app/command_groupmsg_test.go +++ b/app/command_groupmsg_test.go @@ -10,35 +10,44 @@ import ( ) func TestGroupMsgUsernames(t *testing.T) { - if users, parsedMessage := groupMsgUsernames(""); len(users) != 0 || parsedMessage != "" { - t.Fatal("error parsing empty message") - } - if users, parsedMessage := groupMsgUsernames("test"); len(users) != 1 || parsedMessage != "" { - t.Fatal("error parsing simple user") - } - if users, parsedMessage := groupMsgUsernames("test1, test2, test3 , test4"); len(users) != 4 || parsedMessage != "" { - t.Fatal("error parsing various users") - } + assert := assert.New(t) - if users, parsedMessage := groupMsgUsernames("test1, test2 message with spaces"); len(users) != 2 || parsedMessage != "message with spaces" { - t.Fatal("error parsing message") - } + users, parsedMessage := groupMsgUsernames("") + assert.Len(users, 0) + assert.Empty(parsedMessage) - if users, parsedMessage := groupMsgUsernames("test1, test2 message with, comma"); len(users) != 2 || parsedMessage != "message with, comma" { - t.Fatal("error parsing messages with comma") - } + users, parsedMessage = groupMsgUsernames("test") + assert.Len(users, 1) + assert.Empty(parsedMessage) - if users, parsedMessage := groupMsgUsernames("test1,,,test2"); len(users) != 2 || parsedMessage != "" { - t.Fatal("error parsing multiple commas in username ") - } + users, parsedMessage = groupMsgUsernames("test1, test2, test3 , test4") + assert.Len(users, 4) + assert.Empty(parsedMessage) - if users, parsedMessage := groupMsgUsernames(" test1, test2 other message "); len(users) != 2 || parsedMessage != "other message" { - t.Fatal("error parsing strange usage of spaces") - } + users, parsedMessage = groupMsgUsernames("test1, test2 message with spaces") + assert.Len(users, 2) + assert.Equal(parsedMessage, "message with spaces", "error parsing message") - if users, _ := groupMsgUsernames(" test1, test2,,123,@321,+123"); len(users) != 5 || users[0] != "test1" || users[1] != "test2" || users[2] != "123" || users[3] != "321" || users[4] != "+123" { - t.Fatal("error parsing different types of users") - } + users, parsedMessage = groupMsgUsernames("test1, test2 message with, comma") + assert.Len(users, 2) + assert.Equal(parsedMessage, "message with, comma", "error parsing messages with comma") + + users, parsedMessage = groupMsgUsernames("test1,,,test2") + assert.Len(users, 2) + assert.Empty(parsedMessage) + + users, parsedMessage = groupMsgUsernames(" test1, test2 other message ") + assert.Len(users, 2) + assert.Equal(parsedMessage, "other message", "error parsing strange usage of spaces") + + users, _ = groupMsgUsernames(" test1, test2,,123,@321,+123") + assert.Len(users, 5) + assert.Equal(users[0], "test1") + assert.Equal(users[1], "test2") + assert.Equal(users[2], "123") + assert.Equal(users[3], "321") + assert.Equal(users[4], "+123") + assert.Equal(parsedMessage, "other message", "error parsing different types of users") } func TestGroupMsgProvider(t *testing.T) { diff --git a/app/config_test.go b/app/config_test.go index 838456e685..b749399acc 100644 --- a/app/config_test.go +++ b/app/config_test.go @@ -68,12 +68,10 @@ func TestClientConfigWithComputed(t *testing.T) { defer th.TearDown() config := th.App.ClientConfigWithComputed() - if _, ok := config["NoAccounts"]; !ok { - t.Fatal("expected NoAccounts in returned config") - } - if _, ok := config["MaxPostSize"]; !ok { - t.Fatal("expected MaxPostSize in returned config") - } + _, ok := config["NoAccounts"] + assert.True(t, ok, "expected NoAccounts in returned config") + _, ok = config["MaxPostSize"] + assert.True(t, ok, "expected MaxPostSize in returned config") } func TestEnsureInstallationDate(t *testing.T) { diff --git a/app/email_batching_test.go b/app/email_batching_test.go index a6ffff478b..09c2511ccf 100644 --- a/app/email_batching_test.go +++ b/app/email_batching_test.go @@ -4,7 +4,7 @@ package app import ( - "strings" + "github.com/stretchr/testify/assert" "testing" "time" @@ -25,54 +25,35 @@ func TestHandleNewNotifications(t *testing.T) { job.handleNewNotifications() - if len(job.pendingNotifications) != 0 { - t.Fatal("shouldn't have added any pending notifications") - } + require.Len(t, job.pendingNotifications, 0, "shouldn't have added any pending notifications") job.Add(&model.User{Id: id1}, &model.Post{UserId: id1, Message: "test"}, &model.Team{Name: "team"}) - if len(job.pendingNotifications) != 0 { - t.Fatal("shouldn't have added any pending notifications") - } + require.Len(t, job.pendingNotifications, 0, "shouldn't have added any pending notifications") job.handleNewNotifications() - if len(job.pendingNotifications) != 1 { - t.Fatal("should have received posts for 1 user") - } else if len(job.pendingNotifications[id1]) != 1 { - t.Fatal("should have received 1 post for user") - } + require.Len(t, job.pendingNotifications, 1, "should have received posts for 1 user") + require.Len(t, job.pendingNotifications[id1], 1, "should have received 1 post for user") job.Add(&model.User{Id: id1}, &model.Post{UserId: id1, Message: "test"}, &model.Team{Name: "team"}) job.handleNewNotifications() - if len(job.pendingNotifications) != 1 { - t.Fatal("should have received posts for 1 user") - } else if len(job.pendingNotifications[id1]) != 2 { - t.Fatal("should have received 2 posts for user1", job.pendingNotifications[id1]) - } + require.Len(t, job.pendingNotifications, 1, "should have received posts for 1 user") + require.Len(t, job.pendingNotifications[id1], 2, "should have received 2 posts for user1") job.Add(&model.User{Id: id2}, &model.Post{UserId: id1, Message: "test"}, &model.Team{Name: "team"}) job.handleNewNotifications() - if len(job.pendingNotifications) != 2 { - t.Fatal("should have received posts for 2 users") - } else if len(job.pendingNotifications[id1]) != 2 { - t.Fatal("should have received 2 posts for user1") - } else if len(job.pendingNotifications[id2]) != 1 { - t.Fatal("should have received 1 post for user2") - } + require.Len(t, job.pendingNotifications, 2, "should have received posts for 2 users") + require.Len(t, job.pendingNotifications[id1], 2, "should have received 2 posts for user1") + require.Len(t, job.pendingNotifications[id2], 1, "should have received 1 post for user2") job.Add(&model.User{Id: id2}, &model.Post{UserId: id2, Message: "test"}, &model.Team{Name: "team"}) job.Add(&model.User{Id: id1}, &model.Post{UserId: id3, Message: "test"}, &model.Team{Name: "team"}) job.Add(&model.User{Id: id3}, &model.Post{UserId: id3, Message: "test"}, &model.Team{Name: "team"}) job.Add(&model.User{Id: id2}, &model.Post{UserId: id2, Message: "test"}, &model.Team{Name: "team"}) job.handleNewNotifications() - if len(job.pendingNotifications) != 3 { - t.Fatal("should have received posts for 3 users") - } else if len(job.pendingNotifications[id1]) != 3 { - t.Fatal("should have received 3 posts for user1") - } else if len(job.pendingNotifications[id2]) != 3 { - t.Fatal("should have received 3 posts for user2") - } else if len(job.pendingNotifications[id3]) != 1 { - t.Fatal("should have received 1 post for user3") - } + require.Len(t, job.pendingNotifications, 3, "should have received posts for 3 users") + require.Len(t, job.pendingNotifications[id1], 3, "should have received 3 posts for user1") + require.Len(t, job.pendingNotifications[id2], 3, "should have received 3 posts for user2") + require.Len(t, job.pendingNotifications[id3], 1, "should have received 1 post for user3") // test ordering of received posts job = NewEmailBatchingJob(th.Server, 128) @@ -83,14 +64,11 @@ func TestHandleNewNotifications(t *testing.T) { job.Add(&model.User{Id: id1}, &model.Post{UserId: id1, Message: "test4"}, &model.Team{Name: "team"}) job.Add(&model.User{Id: id2}, &model.Post{UserId: id1, Message: "test5"}, &model.Team{Name: "team"}) job.handleNewNotifications() - if job.pendingNotifications[id1][0].post.Message != "test1" || - job.pendingNotifications[id1][1].post.Message != "test2" || - job.pendingNotifications[id1][2].post.Message != "test4" { - t.Fatal("incorrect order of received posts for user1") - } else if job.pendingNotifications[id2][0].post.Message != "test3" || - job.pendingNotifications[id2][1].post.Message != "test5" { - t.Fatal("incorrect order of received posts for user2") - } + assert.Equal(t, job.pendingNotifications[id1][0].post.Message, "test1", "incorrect order of received posts for user1"); + assert.Equal(t, job.pendingNotifications[id1][1].post.Message, "test2", "incorrect order of received posts for user1"); + assert.Equal(t, job.pendingNotifications[id1][2].post.Message, "test4", "incorrect order of received posts for user1"); + assert.Equal(t, job.pendingNotifications[id2][0].post.Message, "test3", "incorrect order of received posts for user2"); + assert.Equal(t, job.pendingNotifications[id2][1].post.Message, "test5", "incorrect order of received posts for user2"); } func TestCheckPendingNotifications(t *testing.T) { @@ -126,9 +104,8 @@ func TestCheckPendingNotifications(t *testing.T) { // test that notifications aren't sent before interval job.checkPendingNotifications(time.Unix(10001, 0), func(string, []*batchedNotification) {}) - if job.pendingNotifications[th.BasicUser.Id] == nil || len(job.pendingNotifications[th.BasicUser.Id]) != 1 { - t.Fatal("shouldn't have sent queued post") - } + require.NotNil(t, job.pendingNotifications[th.BasicUser.Id]) + require.Len(t, job.pendingNotifications[th.BasicUser.Id], 1, "shouldn't have sent queued post") // test that notifications are cleared if the user has acted channelMember, err = th.App.Srv.Store.Channel().GetMember(th.BasicChannel.Id, th.BasicUser.Id) @@ -139,9 +116,8 @@ func TestCheckPendingNotifications(t *testing.T) { job.checkPendingNotifications(time.Unix(10002, 0), func(string, []*batchedNotification) {}) - if job.pendingNotifications[th.BasicUser.Id] != nil && len(job.pendingNotifications[th.BasicUser.Id]) != 0 { - t.Fatal("should've remove queued post since user acted") - } + require.Nil(t, job.pendingNotifications[th.BasicUser.Id]) + require.Len(t, job.pendingNotifications[th.BasicUser.Id], 0, "should've remove queued post since user acted") // test that notifications are sent if enough time passes since the first message job.pendingNotifications[th.BasicUser.Id] = []*batchedNotification{ @@ -180,26 +156,22 @@ func TestCheckPendingNotifications(t *testing.T) { timeout <- true }() - if job.pendingNotifications[th.BasicUser.Id] != nil && len(job.pendingNotifications[th.BasicUser.Id]) != 0 { - t.Fatal("should've remove queued posts when sending messages") + require.Nil(t, job.pendingNotifications[th.BasicUser.Id], "shouldn't have sent queued post") + + select { + case post := <-received: + require.Equal(t, post.Message, "post1", "should've received post1 first") + + case <-timeout: + require.Fail(t, "timed out waiting for first post notification") } select { case post := <-received: - if post.Message != "post1" { - t.Fatal("should've received post1 first") - } - case <-timeout: - t.Fatal("timed out waiting for first post notification") - } + require.Equal(t, post.Message, "post2", "should've received post2 second") - select { - case post := <-received: - if post.Message != "post2" { - t.Fatal("should've received post2 second") - } case <-timeout: - t.Fatal("timed out waiting for second post notification") + require.Fail(t, "timed out waiting for second post notification") } } @@ -232,15 +204,13 @@ func TestCheckPendingNotificationsDefaultInterval(t *testing.T) { // notifications should not be sent 1s after post was created, because default batch interval is 15mins job.checkPendingNotifications(time.Unix(10001, 0), func(string, []*batchedNotification) {}) - if job.pendingNotifications[th.BasicUser.Id] == nil || len(job.pendingNotifications[th.BasicUser.Id]) != 1 { - t.Fatal("shouldn't have sent queued post") - } + require.NotNil(t, job.pendingNotifications[th.BasicUser.Id]) + require.Len(t, job.pendingNotifications[th.BasicUser.Id], 1, "shouldn't have sent queued post") // notifications should be sent 901s after post was created, because default batch interval is 15mins job.checkPendingNotifications(time.Unix(10901, 0), func(string, []*batchedNotification) {}) - if job.pendingNotifications[th.BasicUser.Id] != nil || len(job.pendingNotifications[th.BasicUser.Id]) != 0 { - t.Fatal("should have sent queued post") - } + require.Nil(t, job.pendingNotifications[th.BasicUser.Id]) + require.Len(t, job.pendingNotifications[th.BasicUser.Id], 0, "should have sent queued post") } /** @@ -281,15 +251,13 @@ func TestCheckPendingNotificationsCantParseInterval(t *testing.T) { // notifications should not be sent 1s after post was created, because default batch interval is 15mins job.checkPendingNotifications(time.Unix(10001, 0), func(string, []*batchedNotification) {}) - if job.pendingNotifications[th.BasicUser.Id] == nil || len(job.pendingNotifications[th.BasicUser.Id]) != 1 { - t.Fatal("shouldn't have sent queued post") - } + require.NotNil(t, job.pendingNotifications[th.BasicUser.Id]) + require.Len(t, job.pendingNotifications[th.BasicUser.Id], 1, "shouldn't have sent queued post") // notifications should be sent 901s after post was created, because default batch interval is 15mins job.checkPendingNotifications(time.Unix(10901, 0), func(string, []*batchedNotification) {}) - if job.pendingNotifications[th.BasicUser.Id] != nil || len(job.pendingNotifications[th.BasicUser.Id]) != 0 { - t.Fatal("should have sent queued post") - } + + require.Nil(t, job.pendingNotifications[th.BasicUser.Id], "should have sent queued post") } /* @@ -314,9 +282,7 @@ func TestRenderBatchedPostGeneric(t *testing.T) { } var rendered = th.Server.renderBatchedPost(notification, channel, sender, "http://localhost:8065", "", translateFunc, "en", model.EMAIL_NOTIFICATION_CONTENTS_GENERIC) - if strings.Contains(rendered, post.Message) { - t.Fatal("Rendered email should not contain post contents when email notification contents type is set to Generic.") - } + require.NotContains(t, rendered, post.Message, "Rendered email should not contain post contents when email notification contents type is set to Generic.") } /* @@ -341,7 +307,5 @@ func TestRenderBatchedPostFull(t *testing.T) { } var rendered = th.Server.renderBatchedPost(notification, channel, sender, "http://localhost:8065", "", translateFunc, "en", model.EMAIL_NOTIFICATION_CONTENTS_FULL) - if !strings.Contains(rendered, post.Message) { - t.Fatal("Rendered email should contain post contents when email notification contents type is set to Full.") - } + require.Contains(t, rendered, post.Message, "Rendered email should contain post contents when email notification contents type is set to Full.") } diff --git a/app/import_functions.go b/app/import_functions.go index 3078ddf37e..a5043ae9fd 100644 --- a/app/import_functions.go +++ b/app/import_functions.go @@ -6,7 +6,6 @@ package app import ( "bytes" "crypto/sha1" - "fmt" "io" "net/http" "os" @@ -935,7 +934,7 @@ func (a *App) ImportAttachment(data *AttachmentImportData, post *model.Post, tea oldHash := sha1.Sum(oldFileData) if bytes.Equal(oldHash[:], newHash[:]) { - mlog.Info(fmt.Sprintf("Skipping uploading of file with name %s, already exists", file.Name())) + mlog.Info("Skipping uploading of file because name already exists", mlog.Any("file_name", file.Name())) return nil, nil } @@ -947,13 +946,13 @@ func (a *App) ImportAttachment(data *AttachmentImportData, post *model.Post, tea fileInfo, err := a.DoUploadFile(timestamp, teamId, post.ChannelId, post.UserId, file.Name(), buf.Bytes()) if err != nil { - mlog.Error(fmt.Sprintf("Failed to upload file: %s", err.Error())) + mlog.Error("Failed to upload file:", mlog.Err(err)) return nil, err } a.HandleImages([]string{fileInfo.PreviewPath}, []string{fileInfo.ThumbnailPath}, [][]byte{buf.Bytes()}) - mlog.Info(fmt.Sprintf("uploading file with name %s", file.Name())) + mlog.Info("Uploading file with name", mlog.String("file_name", file.Name())) return fileInfo, nil } return nil, model.NewAppError("BulkImport", "app.import.attachment.file_upload.error", map[string]interface{}{"FilePath": *data.Path}, "", http.StatusBadRequest) @@ -1091,7 +1090,7 @@ func (a *App) uploadAttachments(attachments *[]AttachmentImportData, post *model func (a *App) UpdateFileInfoWithPostId(post *model.Post) { for _, fileId := range post.FileIds { if err := a.Srv.Store.FileInfo().AttachToPost(fileId, post.Id, post.UserId); err != nil { - mlog.Error(fmt.Sprintf("Error attaching files to post. postId=%v, fileIds=%v, message=%v", post.Id, post.FileIds, err), mlog.String("post_id", post.Id)) + mlog.Error("Error attaching files to post.", mlog.String("post_id", post.Id), mlog.Any("post_file_ids", post.FileIds), mlog.Err(err)) } } } diff --git a/app/import_validators_test.go b/app/import_validators_test.go index 891702e9d9..48de801350 100644 --- a/app/import_validators_test.go +++ b/app/import_validators_test.go @@ -8,6 +8,8 @@ import ( "strings" "testing" + "github.com/stretchr/testify/require" + "github.com/mattermost/mattermost-server/model" "github.com/mattermost/mattermost-server/utils/fileutils" "github.com/stretchr/testify/assert" @@ -50,60 +52,58 @@ func TestImportValidateSchemeImportData(t *testing.T) { Permissions: &[]string{"invite_user"}, }, } - if err := validateSchemeImportData(&data); err != nil { - t.Fatal("Validation failed but should have been valid.", err) - } + + err := validateSchemeImportData(&data) + require.Nil(t, err, "Validation failed but should have been valid.") // Test with various invalid names. data.Name = nil - if err := validateSchemeImportData(&data); err == nil { - t.Fatal("Should have failed due to invalid name.") - } + err = validateSchemeImportData(&data) + require.NotNil(t, err, "Should have failed due to invalid name.") + // Test with empty string data.Name = ptrStr("") - if err := validateSchemeImportData(&data); err == nil { - t.Fatal("Should have failed due to invalid name.") - } + err = validateSchemeImportData(&data) + require.NotNil(t, err, "Should have failed due to invalid name.") + // Test with numbers data.Name = ptrStr(strings.Repeat("1234567890", 100)) - if err := validateSchemeImportData(&data); err == nil { - t.Fatal("Should have failed due to invalid name.") - } + err = validateSchemeImportData(&data) + require.NotNil(t, err, "Should have failed due to invalid name.") data.Name = ptrStr("name") + // Test with invalid display name. data.DisplayName = nil - if err := validateSchemeImportData(&data); err == nil { - t.Fatal("Should have failed due to invalid display name.") - } + err = validateSchemeImportData(&data) + require.NotNil(t, err, "Should have failed due to invalid display name.") + // Test with display name. data.DisplayName = ptrStr("") - if err := validateSchemeImportData(&data); err == nil { - t.Fatal("Should have failed due to invalid display name.") - } + err = validateSchemeImportData(&data) + require.NotNil(t, err, "Should have failed due to invalid display name.") + // Test display name with numbers data.DisplayName = ptrStr(strings.Repeat("1234567890", 100)) - if err := validateSchemeImportData(&data); err == nil { - t.Fatal("Should have failed due to invalid display name.") - } + err = validateSchemeImportData(&data) + require.NotNil(t, err, "Should have failed due to invalid display name.") data.DisplayName = ptrStr("display name") // Test with various missing roles. data.DefaultTeamAdminRole = nil - if err := validateSchemeImportData(&data); err == nil { - t.Fatal("Should have failed due to missing role.") - } + err = validateSchemeImportData(&data) + require.NotNil(t, err, "Should have failed due to missing role.") data.DefaultTeamAdminRole = &RoleImportData{ Name: ptrStr("name"), DisplayName: ptrStr("display name"), Permissions: &[]string{"invite_user"}, } + data.DefaultTeamUserRole = nil - if err := validateSchemeImportData(&data); err == nil { - t.Fatal("Should have failed due to missing role.") - } + err = validateSchemeImportData(&data) + require.NotNil(t, err, "Should have failed due to missing role.") data.DefaultTeamUserRole = &RoleImportData{ Name: ptrStr("name"), @@ -111,9 +111,8 @@ func TestImportValidateSchemeImportData(t *testing.T) { Permissions: &[]string{"invite_user"}, } data.DefaultChannelAdminRole = nil - if err := validateSchemeImportData(&data); err == nil { - t.Fatal("Should have failed due to missing role.") - } + err = validateSchemeImportData(&data) + require.NotNil(t, err, "Should have failed due to missing role.") data.DefaultChannelAdminRole = &RoleImportData{ Name: ptrStr("name"), @@ -121,9 +120,8 @@ func TestImportValidateSchemeImportData(t *testing.T) { Permissions: &[]string{"invite_user"}, } data.DefaultChannelUserRole = nil - if err := validateSchemeImportData(&data); err == nil { - t.Fatal("Should have failed due to missing role.") - } + err = validateSchemeImportData(&data) + require.NotNil(t, err, "Should have failed due to missing role.") data.DefaultChannelUserRole = &RoleImportData{ Name: ptrStr("name"), @@ -133,36 +131,31 @@ func TestImportValidateSchemeImportData(t *testing.T) { // Test with various invalid roles. data.DefaultTeamAdminRole.Name = nil - if err := validateSchemeImportData(&data); err == nil { - t.Fatal("Should have failed due to invalid role.") - } + err = validateSchemeImportData(&data) + require.NotNil(t, err, "Should have failed due to invalid role.") data.DefaultTeamAdminRole.Name = ptrStr("name") data.DefaultTeamUserRole.Name = nil - if err := validateSchemeImportData(&data); err == nil { - t.Fatal("Should have failed due to invalid role.") - } + err = validateSchemeImportData(&data) + require.NotNil(t, err, "Should have failed due to invalid role.") data.DefaultTeamUserRole.Name = ptrStr("name") data.DefaultChannelAdminRole.Name = nil - if err := validateSchemeImportData(&data); err == nil { - t.Fatal("Should have failed due to invalid role.") - } + err = validateSchemeImportData(&data) + require.NotNil(t, err, "Should have failed due to invalid role.") data.DefaultChannelAdminRole.Name = ptrStr("name") data.DefaultChannelUserRole.Name = nil - if err := validateSchemeImportData(&data); err == nil { - t.Fatal("Should have failed due to invalid role.") - } + err = validateSchemeImportData(&data) + require.NotNil(t, err, "Should have failed due to invalid role.") data.DefaultChannelUserRole.Name = ptrStr("name") // Change to a Channel scope role, and check with missing or extra roles again. data.Scope = ptrStr("channel") data.DefaultTeamAdminRole = nil - if err := validateSchemeImportData(&data); err == nil { - t.Fatal("Should have failed due to spurious role.") - } + err = validateSchemeImportData(&data) + require.NotNil(t, err, "Should have failed due to spurious role.") data.DefaultTeamAdminRole = &RoleImportData{ Name: ptrStr("name"), @@ -170,9 +163,8 @@ func TestImportValidateSchemeImportData(t *testing.T) { Permissions: &[]string{"invite_user"}, } data.DefaultTeamUserRole = nil - if err := validateSchemeImportData(&data); err == nil { - t.Fatal("Should have failed due to spurious role.") - } + err = validateSchemeImportData(&data) + require.NotNil(t, err, "Should have failed due to spurious role.") data.DefaultTeamUserRole = &RoleImportData{ Name: ptrStr("name"), @@ -180,27 +172,23 @@ func TestImportValidateSchemeImportData(t *testing.T) { Permissions: &[]string{"invite_user"}, } data.DefaultTeamGuestRole = nil - if err := validateSchemeImportData(&data); err == nil { - t.Fatal("Should have failed due to spurious role.") - } + err = validateSchemeImportData(&data) + require.NotNil(t, err, "Should have failed due to spurious role.") data.DefaultTeamGuestRole = nil data.DefaultTeamUserRole = nil data.DefaultTeamAdminRole = nil - if err := validateSchemeImportData(&data); err != nil { - t.Fatal("Should have succeeded.") - } + err = validateSchemeImportData(&data) + require.Nil(t, err, "Should have succeeded.") // Test with all combinations of optional parameters. data.Description = ptrStr(strings.Repeat("1234567890", 1024)) - if err := validateSchemeImportData(&data); err == nil { - t.Fatal("Should have failed due to invalid description.") - } + err = validateSchemeImportData(&data) + require.NotNil(t, err, "Should have failed due to invalid description.") data.Description = ptrStr("description") - if err := validateSchemeImportData(&data); err != nil { - t.Fatal("Should have succeeded.") - } + err = validateSchemeImportData(&data) + require.Nil(t, err, "Should have succeeded.") } func TestImportValidateRoleImportData(t *testing.T) { @@ -209,73 +197,62 @@ func TestImportValidateRoleImportData(t *testing.T) { Name: ptrStr("name"), DisplayName: ptrStr("display name"), } - if err := validateRoleImportData(&data); err != nil { - t.Fatal("Validation failed but should have been valid.", err) - } + err := validateRoleImportData(&data) + require.Nil(t, err, "Validation failed but should have been valid.") // Test with various invalid names. data.Name = nil - if err := validateRoleImportData(&data); err == nil { - t.Fatal("Should have failed due to invalid name.") - } + err = validateRoleImportData(&data) + require.NotNil(t, err, "Should have failed due to invalid name.") data.Name = ptrStr("") - if err := validateRoleImportData(&data); err == nil { - t.Fatal("Should have failed due to invalid name.") - } + err = validateRoleImportData(&data) + require.NotNil(t, err, "Should have failed due to invalid name.") data.Name = ptrStr(strings.Repeat("1234567890", 100)) - if err := validateRoleImportData(&data); err == nil { - t.Fatal("Should have failed due to invalid name.") - } + err = validateRoleImportData(&data) + require.NotNil(t, err, "Should have failed due to invalid name.") data.Name = ptrStr("name") + // Test with invalid display name. data.DisplayName = nil - if err := validateRoleImportData(&data); err == nil { - t.Fatal("Should have failed due to invalid display name.") - } + err = validateRoleImportData(&data) + require.NotNil(t, err, "Should have failed due to invalid display name.") data.DisplayName = ptrStr("") - if err := validateRoleImportData(&data); err == nil { - t.Fatal("Should have failed due to invalid display name.") - } + err = validateRoleImportData(&data) + require.NotNil(t, err, "Should have failed due to invalid display name.") data.DisplayName = ptrStr(strings.Repeat("1234567890", 100)) - if err := validateRoleImportData(&data); err == nil { - t.Fatal("Should have failed due to invalid display name.") - } + err = validateRoleImportData(&data) + require.NotNil(t, err, "Should have failed due to invalid display name.") data.DisplayName = ptrStr("display name") // Test with various valid/invalid permissions. data.Permissions = &[]string{} - if err := validateRoleImportData(&data); err != nil { - t.Fatal("Validation failed but should have been valid.", err) - } + err = validateRoleImportData(&data) + require.Nil(t, err, "Validation failed but should have been valid.") data.Permissions = &[]string{"invite_user", "add_user_to_team"} - if err := validateRoleImportData(&data); err != nil { - t.Fatal("Validation failed but should have been valid.", err) - } + err = validateRoleImportData(&data) + require.Nil(t, err, "Validation failed but should have been valid.") data.Permissions = &[]string{"invite_user", "add_user_to_team", "derp"} - if err := validateRoleImportData(&data); err == nil { - t.Fatal("Validation should have failed due to invalid permission.", err) - } + err = validateRoleImportData(&data) + require.NotNil(t, err, "Validation should have failed due to invalid permission.") data.Permissions = &[]string{"invite_user", "add_user_to_team"} // Test with various valid/invalid descriptions. data.Description = ptrStr(strings.Repeat("1234567890", 1024)) - if err := validateRoleImportData(&data); err == nil { - t.Fatal("Validation should have failed due to invalid description.", err) - } + err = validateRoleImportData(&data) + require.NotNil(t, err, "Validation should have failed due to invalid description.") data.Description = ptrStr("description") - if err := validateRoleImportData(&data); err != nil { - t.Fatal("Validation failed but should have been valid.", err) - } + err = validateRoleImportData(&data) + require.Nil(t, err, "Validation failed but should have been valid.") } func TestImportValidateTeamImportData(t *testing.T) { @@ -286,76 +263,64 @@ func TestImportValidateTeamImportData(t *testing.T) { DisplayName: ptrStr("Display Name"), Type: ptrStr("O"), } - if err := validateTeamImportData(&data); err != nil { - t.Fatal("Validation failed but should have been valid.") - } + err := validateTeamImportData(&data) + require.Nil(t, err, "Validation failed but should have been valid.") // Test with various invalid names. data = TeamImportData{ DisplayName: ptrStr("Display Name"), Type: ptrStr("O"), } - if err := validateTeamImportData(&data); err == nil { - t.Fatal("Should have failed due to missing name.") - } + err = validateTeamImportData(&data) + require.NotNil(t, err, "Should have failed due to missing name.") data.Name = ptrStr(strings.Repeat("abcdefghij", 7)) - if err := validateTeamImportData(&data); err == nil { - t.Fatal("Should have failed due to too long name.") - } + err = validateTeamImportData(&data) + require.NotNil(t, err, "Should have failed due to too long name.") data.Name = ptrStr("login") - if err := validateTeamImportData(&data); err == nil { - t.Fatal("Should have failed due to reserved word in name.") - } + err = validateTeamImportData(&data) + require.NotNil(t, err, "Should have failed due to reserved word in name.") data.Name = ptrStr("Test::''ASD") - if err := validateTeamImportData(&data); err == nil { - t.Fatal("Should have failed due to non alphanum characters in name.") - } + err = validateTeamImportData(&data) + require.NotNil(t, err, "Should have failed due to non alphanum characters in name.") data.Name = ptrStr("A") - if err := validateTeamImportData(&data); err == nil { - t.Fatal("Should have failed due to short name.") - } + err = validateTeamImportData(&data) + require.NotNil(t, err, "Should have failed due to short name.") // Test team various invalid display names. data = TeamImportData{ Name: ptrStr("teamname"), Type: ptrStr("O"), } - if err := validateTeamImportData(&data); err == nil { - t.Fatal("Should have failed due to missing display_name.") - } + err = validateTeamImportData(&data) + require.NotNil(t, err, "Should have failed due to missing display_name.") data.DisplayName = ptrStr("") - if err := validateTeamImportData(&data); err == nil { - t.Fatal("Should have failed due to empty display_name.") - } + err = validateTeamImportData(&data) + require.NotNil(t, err, "Should have failed due to empty display_name.") data.DisplayName = ptrStr(strings.Repeat("abcdefghij", 7)) - if err := validateTeamImportData(&data); err == nil { - t.Fatal("Should have failed due to too long display_name.") - } + err = validateTeamImportData(&data) + require.NotNil(t, err, "Should have failed due to too long display_name.") // Test with various valid and invalid types. data = TeamImportData{ Name: ptrStr("teamname"), DisplayName: ptrStr("Display Name"), } - if err := validateTeamImportData(&data); err == nil { - t.Fatal("Should have failed due to missing type.") - } + err = validateTeamImportData(&data) + require.NotNil(t, err, "Should have failed due to missing type.") data.Type = ptrStr("A") - if err := validateTeamImportData(&data); err == nil { - t.Fatal("Should have failed due to invalid type.") - } + err = validateTeamImportData(&data) + require.NotNil(t, err, "Should have failed due to invalid type.") data.Type = ptrStr("I") - if err := validateTeamImportData(&data); err != nil { - t.Fatal("Should have succeeded with valid type.") - } + err = validateTeamImportData(&data) + require.Nil(t, err, "Should have succeeded with valid type.") // Test with all the combinations of optional parameters. data = TeamImportData{ @@ -365,32 +330,27 @@ func TestImportValidateTeamImportData(t *testing.T) { Description: ptrStr("The team description."), AllowOpenInvite: ptrBool(true), } - if err := validateTeamImportData(&data); err != nil { - t.Fatal("Should have succeeded with valid optional properties.") - } + err = validateTeamImportData(&data) + require.Nil(t, err, "Should have succeeded with valid optional properties.") data.AllowOpenInvite = ptrBool(false) - if err := validateTeamImportData(&data); err != nil { - t.Fatal("Should have succeeded with allow open invites false.") - } + err = validateTeamImportData(&data) + require.Nil(t, err, "Should have succeeded with allow open invites false.") data.Description = ptrStr(strings.Repeat("abcdefghij ", 26)) - if err := validateTeamImportData(&data); err == nil { - t.Fatal("Should have failed due to too long description.") - } + err = validateTeamImportData(&data) + require.NotNil(t, err, "Should have failed due to too long description.") // Test with an empty scheme name. data.Description = ptrStr("abcdefg") data.Scheme = ptrStr("") - if err := validateTeamImportData(&data); err == nil { - t.Fatal("Should have failed due to empty scheme name.") - } + err = validateTeamImportData(&data) + require.NotNil(t, err, "Should have failed due to empty scheme name.") // Test with a valid scheme name. data.Scheme = ptrStr("abcdefg") - if err := validateTeamImportData(&data); err != nil { - t.Fatal("Should have succeeded with valid scheme name.") - } + err = validateTeamImportData(&data) + require.Nil(t, err, "Should have succeeded with valid scheme name.") } func TestImportValidateChannelImportData(t *testing.T) { @@ -402,9 +362,8 @@ func TestImportValidateChannelImportData(t *testing.T) { DisplayName: ptrStr("Display Name"), Type: ptrStr("O"), } - if err := validateChannelImportData(&data); err != nil { - t.Fatal("Validation failed but should have been valid.") - } + err := validateChannelImportData(&data) + require.Nil(t, err, "Validation failed but should have been valid.") // Test with missing team. data = ChannelImportData{ @@ -412,9 +371,8 @@ func TestImportValidateChannelImportData(t *testing.T) { DisplayName: ptrStr("Display Name"), Type: ptrStr("O"), } - if err := validateChannelImportData(&data); err == nil { - t.Fatal("Should have failed due to missing team.") - } + err = validateChannelImportData(&data) + require.NotNil(t, err, "Should have failed due to missing team.") // Test with various invalid names. data = ChannelImportData{ @@ -422,24 +380,20 @@ func TestImportValidateChannelImportData(t *testing.T) { DisplayName: ptrStr("Display Name"), Type: ptrStr("O"), } - if err := validateChannelImportData(&data); err == nil { - t.Fatal("Should have failed due to missing name.") - } + err = validateChannelImportData(&data) + require.NotNil(t, err, "Should have failed due to missing name.") data.Name = ptrStr(strings.Repeat("abcdefghij", 7)) - if err := validateChannelImportData(&data); err == nil { - t.Fatal("Should have failed due to too long name.") - } + err = validateChannelImportData(&data) + require.NotNil(t, err, "Should have failed due to too long name.") data.Name = ptrStr("Test::''ASD") - if err := validateChannelImportData(&data); err == nil { - t.Fatal("Should have failed due to non alphanum characters in name.") - } + err = validateChannelImportData(&data) + require.NotNil(t, err, "Should have failed due to non alphanum characters in name.") data.Name = ptrStr("A") - if err := validateChannelImportData(&data); err == nil { - t.Fatal("Should have failed due to short name.") - } + err = validateChannelImportData(&data) + require.NotNil(t, err, "Should have failed due to short name.") // Test team various invalid display names. data = ChannelImportData{ @@ -447,19 +401,16 @@ func TestImportValidateChannelImportData(t *testing.T) { Name: ptrStr("channelname"), Type: ptrStr("O"), } - if err := validateChannelImportData(&data); err == nil { - t.Fatal("Should have failed due to missing display_name.") - } + err = validateChannelImportData(&data) + require.NotNil(t, err, "Should have failed due to missing display_name.") data.DisplayName = ptrStr("") - if err := validateChannelImportData(&data); err == nil { - t.Fatal("Should have failed due to empty display_name.") - } + err = validateChannelImportData(&data) + require.NotNil(t, err, "Should have failed due to empty display_name.") data.DisplayName = ptrStr(strings.Repeat("abcdefghij", 7)) - if err := validateChannelImportData(&data); err == nil { - t.Fatal("Should have failed due to too long display_name.") - } + err = validateChannelImportData(&data) + require.NotNil(t, err, "Should have failed due to too long display_name.") // Test with various valid and invalid types. data = ChannelImportData{ @@ -467,19 +418,16 @@ func TestImportValidateChannelImportData(t *testing.T) { Name: ptrStr("channelname"), DisplayName: ptrStr("Display Name"), } - if err := validateChannelImportData(&data); err == nil { - t.Fatal("Should have failed due to missing type.") - } + err = validateChannelImportData(&data) + require.NotNil(t, err, "Should have failed due to missing type.") data.Type = ptrStr("A") - if err := validateChannelImportData(&data); err == nil { - t.Fatal("Should have failed due to invalid type.") - } + err = validateChannelImportData(&data) + require.NotNil(t, err, "Should have failed due to invalid type.") data.Type = ptrStr("P") - if err := validateChannelImportData(&data); err != nil { - t.Fatal("Should have succeeded with valid type.") - } + err = validateChannelImportData(&data) + require.Nil(t, err, "Should have succeeded with valid type.") // Test with all the combinations of optional parameters. data = ChannelImportData{ @@ -490,33 +438,28 @@ func TestImportValidateChannelImportData(t *testing.T) { Header: ptrStr("Channel Header Here"), Purpose: ptrStr("Channel Purpose Here"), } - if err := validateChannelImportData(&data); err != nil { - t.Fatal("Should have succeeded with valid optional properties.") - } + err = validateChannelImportData(&data) + require.Nil(t, err, "Should have succeeded with valid optional properties.") data.Header = ptrStr(strings.Repeat("abcdefghij ", 103)) - if err := validateChannelImportData(&data); err == nil { - t.Fatal("Should have failed due to too long header.") - } + err = validateChannelImportData(&data) + require.NotNil(t, err, "Should have failed due to too long header.") data.Header = ptrStr("Channel Header Here") data.Purpose = ptrStr(strings.Repeat("abcdefghij ", 26)) - if err := validateChannelImportData(&data); err == nil { - t.Fatal("Should have failed due to too long purpose.") - } + err = validateChannelImportData(&data) + require.NotNil(t, err, "Should have failed due to too long purpose.") // Test with an empty scheme name. data.Purpose = ptrStr("abcdefg") data.Scheme = ptrStr("") - if err := validateChannelImportData(&data); err == nil { - t.Fatal("Should have failed due to empty scheme name.") - } + err = validateChannelImportData(&data) + require.NotNil(t, err, "Should have failed due to empty scheme name.") // Test with a valid scheme name. data.Scheme = ptrStr("abcdefg") - if err := validateChannelImportData(&data); err != nil { - t.Fatal("Should have succeeded with valid scheme name.") - } + err = validateChannelImportData(&data) + require.Nil(t, err, "Should have succeeded with valid scheme name.") } func TestImportValidateUserImportData(t *testing.T) { @@ -526,55 +469,47 @@ func TestImportValidateUserImportData(t *testing.T) { Username: ptrStr("bob"), Email: ptrStr("bob@example.com"), } - if err := validateUserImportData(&data); err != nil { - t.Fatal("Validation failed but should have been valid.") - } + err := validateUserImportData(&data) + require.Nil(t, err, "Validation failed but should have been valid.") // Invalid Usernames. data.Username = nil - if err := validateUserImportData(&data); err == nil { - t.Fatal("Validation should have failed due to nil Username.") - } + err = validateUserImportData(&data) + require.NotNil(t, err, "Validation should have failed due to nil Username.") data.Username = ptrStr("") - if err := validateUserImportData(&data); err == nil { - t.Fatal("Validation should have failed due to 0 length Username.") - } + err = validateUserImportData(&data) + require.NotNil(t, err, "Validation should have failed due to 0 length Username.") data.Username = ptrStr(strings.Repeat("abcdefghij", 7)) - if err := validateUserImportData(&data); err == nil { - t.Fatal("Validation should have failed due to too long Username.") - } + err = validateUserImportData(&data) + require.NotNil(t, err, "Validation should have failed due to too long Username.") data.Username = ptrStr("i am a username with spaces and !!!") - if err := validateUserImportData(&data); err == nil { - t.Fatal("Validation should have failed due to invalid characters in Username.") - } + err = validateUserImportData(&data) + require.NotNil(t, err, "Validation should have failed due to invalid characters in Username."); data.Username = ptrStr("bob") // Unexisting Picture Image data.ProfileImage = ptrStr("not-existing-file") - if err := validateUserImportData(&data); err == nil { - t.Fatal("Validation should have failed due to not existing profile image file.") - } + err = validateUserImportData(&data) + require.NotNil(t, err, "Validation should have failed due to not existing profile image file.") + data.ProfileImage = nil // Invalid Emails data.Email = nil - if err := validateUserImportData(&data); err == nil { - t.Fatal("Validation should have failed due to nil Email.") - } + err = validateUserImportData(&data) + require.NotNil(t, err, "Validation should have failed due to nil Email.") data.Email = ptrStr("") - if err := validateUserImportData(&data); err == nil { - t.Fatal("Validation should have failed due to 0 length Email.") - } + err = validateUserImportData(&data) + require.NotNil(t, err, "Validation should have failed due to 0 length Email.") data.Email = ptrStr(strings.Repeat("abcdefghij", 13)) - if err := validateUserImportData(&data); err == nil { - t.Fatal("Validation should have failed due to too long Email.") - } + err = validateUserImportData(&data) + require.NotNil(t, err, "Validation should have failed due to too long Email.") data.Email = ptrStr("bob@example.com") @@ -584,14 +519,12 @@ func TestImportValidateUserImportData(t *testing.T) { data.AuthService = ptrStr("saml") data.AuthData = ptrStr(strings.Repeat("abcdefghij", 15)) - if err := validateUserImportData(&data); err == nil { - t.Fatal("Validation should have failed due to too long auth data.") - } + err = validateUserImportData(&data) + require.NotNil(t, err, "Validation should have failed due to too long auth data.") data.AuthData = ptrStr("bobbytables") - if err := validateUserImportData(&data); err != nil { - t.Fatal("Validation should have succeeded with valid auth service and auth data.") - } + err = validateUserImportData(&data) + require.Nil(t, err, "Validation should have succeeded with valid auth service and auth data.") // Test a valid User with all fields populated. testsDir, _ := fileutils.FindDir("tests") @@ -608,44 +541,42 @@ func TestImportValidateUserImportData(t *testing.T) { Roles: ptrStr("system_user"), Locale: ptrStr("en"), } - if err := validateUserImportData(&data); err != nil { - t.Fatal("Validation failed but should have been valid.") - } + err = validateUserImportData(&data) + require.Nil(t, err, "Validation failed but should have been valid.") // Test various invalid optional field values. data.Nickname = ptrStr(strings.Repeat("abcdefghij", 7)) - if err := validateUserImportData(&data); err == nil { - t.Fatal("Validation should have failed due to too long Nickname.") - } + err = validateUserImportData(&data) + require.NotNil(t, err, "Validation should have failed due to too long Nickname.") + data.Nickname = ptrStr("BobNick") data.FirstName = ptrStr(strings.Repeat("abcdefghij", 7)) - if err := validateUserImportData(&data); err == nil { - t.Fatal("Validation should have failed due to too long First Name.") - } + err = validateUserImportData(&data) + require.NotNil(t, err, "Validation should have failed due to too long First Name.") + data.FirstName = ptrStr("Bob") data.LastName = ptrStr(strings.Repeat("abcdefghij", 7)) - if err := validateUserImportData(&data); err == nil { - t.Fatal("Validation should have failed due to too long Last name.") - } + err = validateUserImportData(&data) + require.NotNil(t, err, "Validation should have failed due to too long Last name.") + data.LastName = ptrStr("Blob") data.Position = ptrStr(strings.Repeat("abcdefghij", 13)) - if err := validateUserImportData(&data); err == nil { - t.Fatal("Validation should have failed due to too long Position.") - } + err = validateUserImportData(&data) + require.NotNil(t, err, "Validation should have failed due to too long Position.") + data.Position = ptrStr("The Boss") data.Roles = nil - if err := validateUserImportData(&data); err != nil { - t.Fatal("Validation failed but should have been valid.") - } + err = validateUserImportData(&data) + require.Nil(t, err, "Validation failed but should have been valid.") data.Roles = ptrStr("") - if err := validateUserImportData(&data); err != nil { - t.Fatal("Validation failed but should have been valid.") - } + err = validateUserImportData(&data) + require.Nil(t, err, "Validation failed but should have been valid.") + data.Roles = ptrStr("system_user") // Try various valid/invalid notify props. @@ -709,46 +640,41 @@ func TestImportValidateUserTeamsImportData(t *testing.T) { Roles: ptrStr("team_admin team_user"), }, } - if err := validateUserTeamsImportData(&data); err == nil { - t.Fatal("Should have failed due to invalid name.") - } + err := validateUserTeamsImportData(&data) + require.NotNil(t, err, "Should have failed due to invalid name.") + data[0].Name = ptrStr("teamname") // Valid (nil roles) data[0].Roles = nil - if err := validateUserTeamsImportData(&data); err != nil { - t.Fatal("Should have succeeded with empty roles.") - } + err = validateUserTeamsImportData(&data) + require.Nil(t, err, "Should have succeeded with empty roles.") // Valid (empty roles) data[0].Roles = ptrStr("") - if err := validateUserTeamsImportData(&data); err != nil { - t.Fatal("Should have succeeded with empty roles.") - } + err = validateUserTeamsImportData(&data) + require.Nil(t, err, "Should have succeeded with empty roles.") // Valid (with roles) data[0].Roles = ptrStr("team_admin team_user") - if err := validateUserTeamsImportData(&data); err != nil { - t.Fatal("Should have succeeded with valid roles.") - } + err = validateUserTeamsImportData(&data) + require.Nil(t, err, "Should have succeeded with valid roles.") // Valid (with JSON string of theme) data[0].Theme = ptrStr(`{"awayIndicator":"#DBBD4E","buttonBg":"#23A1FF","buttonColor":"#FFFFFF","centerChannelBg":"#ffffff","centerChannelColor":"#333333","codeTheme":"github","image":"/static/files/a4a388b38b32678e83823ef1b3e17766.png","linkColor":"#2389d7","mentionBg":"#2389d7","mentionColor":"#ffffff","mentionHighlightBg":"#fff2bb","mentionHighlightLink":"#2f81b7","newMessageSeparator":"#FF8800","onlineIndicator":"#7DBE00","sidebarBg":"#fafafa","sidebarHeaderBg":"#3481B9","sidebarHeaderTextColor":"#ffffff","sidebarText":"#333333","sidebarTextActiveBorder":"#378FD2","sidebarTextActiveColor":"#111111","sidebarTextHoverBg":"#e6f2fa","sidebarUnreadText":"#333333","type":"Mattermost"}`) - if err := validateUserTeamsImportData(&data); err != nil { - t.Fatal("Should have succeeded with valid theme.") - } + err = validateUserTeamsImportData(&data) + require.Nil(t, err, "Should have succeeded with valid theme.") // Invalid (invalid JSON string of theme) data[0].Theme = ptrStr(`This is the invalid string which cannot be marshalled to JSON object :) + {"#DBBD4E","buttonBg", "#23A1FF", buttonColor`) - if err := validateUserTeamsImportData(&data); err == nil { - t.Fatal("Should have fail with invalid JSON string of theme.") - } + err = validateUserTeamsImportData(&data) + require.NotNil(t, err, "Should have fail with invalid JSON string of theme.") // Invalid (valid JSON but invalid theme description) data[0].Theme = ptrStr(`{"somekey": 25, "json_obj1": {"color": "#DBBD4E","buttonBg": "#23A1FF"}}`) - if err := validateUserTeamsImportData(&data); err == nil { - t.Fatal("Should have fail with valid JSON which contains invalid string of theme description.") - } + err = validateUserTeamsImportData(&data) + require.NotNil(t, err, "Should have fail with valid JSON which contains invalid string of theme description.") + data[0].Theme = nil } @@ -760,60 +686,51 @@ func TestImportValidateUserChannelsImportData(t *testing.T) { Roles: ptrStr("channel_admin channel_user"), }, } - if err := validateUserChannelsImportData(&data); err == nil { - t.Fatal("Should have failed due to invalid name.") - } + err := validateUserChannelsImportData(&data) + require.NotNil(t, err, "Should have failed due to invalid name.") data[0].Name = ptrStr("channelname") // Valid (nil roles) data[0].Roles = nil - if err := validateUserChannelsImportData(&data); err != nil { - t.Fatal("Should have succeeded with empty roles.") - } + err = validateUserChannelsImportData(&data) + require.Nil(t, err, "Should have succeeded with empty roles.") // Valid (empty roles) data[0].Roles = ptrStr("") - if err := validateUserChannelsImportData(&data); err != nil { - t.Fatal("Should have succeeded with empty roles.") - } + err = validateUserChannelsImportData(&data) + require.Nil(t, err, "Should have succeeded with empty roles.") // Valid (with roles) data[0].Roles = ptrStr("channel_admin channel_user") - if err := validateUserChannelsImportData(&data); err != nil { - t.Fatal("Should have succeeded with valid roles.") - } + err = validateUserChannelsImportData(&data) + require.Nil(t, err, "Should have succeeded with valid roles.") // Empty notify props. data[0].NotifyProps = &UserChannelNotifyPropsImportData{} - if err := validateUserChannelsImportData(&data); err != nil { - t.Fatal("Should have succeeded with empty notify props.") - } + err = validateUserChannelsImportData(&data) + require.Nil(t, err, "Should have succeeded with empty notify props.") // Invalid desktop notify props. data[0].NotifyProps.Desktop = ptrStr("invalid") - if err := validateUserChannelsImportData(&data); err == nil { - t.Fatal("Should have failed with invalid desktop notify props.") - } + err = validateUserChannelsImportData(&data) + require.NotNil(t, err, "Should have failed with invalid desktop notify props.") // Invalid mobile notify props. data[0].NotifyProps.Desktop = ptrStr("mention") data[0].NotifyProps.Mobile = ptrStr("invalid") - if err := validateUserChannelsImportData(&data); err == nil { - t.Fatal("Should have failed with invalid mobile notify props.") - } + err = validateUserChannelsImportData(&data) + require.NotNil(t, err, "Should have failed with invalid mobile notify props.") // Invalid mark_unread notify props. data[0].NotifyProps.Mobile = ptrStr("mention") data[0].NotifyProps.MarkUnread = ptrStr("invalid") - if err := validateUserChannelsImportData(&data); err == nil { - t.Fatal("Should have failed with invalid mark_unread notify props.") - } + err = validateUserChannelsImportData(&data) + require.NotNil(t, err, "Should have failed with invalid mark_unread notify props.") // Valid notify props. data[0].NotifyProps.MarkUnread = ptrStr("mention") - if err := validateUserChannelsImportData(&data); err != nil { - t.Fatal("Should have succeeded with valid notify props.") - } + err = validateUserChannelsImportData(&data) + require.Nil(t, err, "Should have succeeded with valid notify props.") } func TestImportValidateReactionImportData(t *testing.T) { @@ -824,34 +741,31 @@ func TestImportValidateReactionImportData(t *testing.T) { EmojiName: ptrStr("emoji"), CreateAt: ptrInt64(model.GetMillis()), } - if err := validateReactionImportData(&data, parentCreateAt); err != nil { - t.Fatal("Validation failed but should have been valid.") - } + err := validateReactionImportData(&data, parentCreateAt) + require.Nil(t, err, "Validation failed but should have been valid.") // Test with missing required properties. data = ReactionImportData{ EmojiName: ptrStr("emoji"), CreateAt: ptrInt64(model.GetMillis()), } - if err := validateReactionImportData(&data, parentCreateAt); err == nil { - t.Fatal("Should have failed due to missing required property.") - } + err = validateReactionImportData(&data, parentCreateAt) + require.NotNil(t, err, "Should have failed due to missing required property.") data = ReactionImportData{ User: ptrStr("username"), CreateAt: ptrInt64(model.GetMillis()), } - if err := validateReactionImportData(&data, parentCreateAt); err == nil { - t.Fatal("Should have failed due to missing required property.") - } + err = validateReactionImportData(&data, parentCreateAt) + require.NotNil(t, err, "Should have failed due to missing required property.") + data = ReactionImportData{ User: ptrStr("username"), EmojiName: ptrStr("emoji"), } - if err := validateReactionImportData(&data, parentCreateAt); err == nil { - t.Fatal("Should have failed due to missing required property.") - } + err = validateReactionImportData(&data, parentCreateAt) + require.NotNil(t, err, "Should have failed due to missing required property.") // Test with invalid emoji name. data = ReactionImportData{ @@ -859,9 +773,8 @@ func TestImportValidateReactionImportData(t *testing.T) { EmojiName: ptrStr(strings.Repeat("1234567890", 500)), CreateAt: ptrInt64(model.GetMillis()), } - if err := validateReactionImportData(&data, parentCreateAt); err == nil { - t.Fatal("Should have failed due to too long emoji name.") - } + err = validateReactionImportData(&data, parentCreateAt) + require.NotNil(t, err, "Should have failed due to too long emoji name.") // Test with invalid CreateAt data = ReactionImportData{ @@ -869,18 +782,16 @@ func TestImportValidateReactionImportData(t *testing.T) { EmojiName: ptrStr("emoji"), CreateAt: ptrInt64(0), } - if err := validateReactionImportData(&data, parentCreateAt); err == nil { - t.Fatal("Should have failed due to 0 create-at value.") - } + err = validateReactionImportData(&data, parentCreateAt) + require.NotNil(t, err, "Should have failed due to 0 create-at value.") data = ReactionImportData{ User: ptrStr("username"), EmojiName: ptrStr("emoji"), CreateAt: ptrInt64(parentCreateAt - 100), } - if err := validateReactionImportData(&data, parentCreateAt); err == nil { - t.Fatal("Should have failed due parent with newer create-at value.") - } + err = validateReactionImportData(&data, parentCreateAt) + require.NotNil(t, err, "Should have failed due parent with newer create-at value.") } func TestImportValidateReplyImportData(t *testing.T) { @@ -892,34 +803,30 @@ func TestImportValidateReplyImportData(t *testing.T) { Message: ptrStr("message"), CreateAt: ptrInt64(model.GetMillis()), } - if err := validateReplyImportData(&data, parentCreateAt, maxPostSize); err != nil { - t.Fatal("Validation failed but should have been valid.") - } + err := validateReplyImportData(&data, parentCreateAt, maxPostSize) + require.Nil(t, err, "Validation failed but should have been valid.") // Test with missing required properties. data = ReplyImportData{ Message: ptrStr("message"), CreateAt: ptrInt64(model.GetMillis()), } - if err := validateReplyImportData(&data, parentCreateAt, maxPostSize); err == nil { - t.Fatal("Should have failed due to missing required property.") - } + err = validateReplyImportData(&data, parentCreateAt, maxPostSize) + require.NotNil(t, err, "Should have failed due to missing required property.") data = ReplyImportData{ User: ptrStr("username"), CreateAt: ptrInt64(model.GetMillis()), } - if err := validateReplyImportData(&data, parentCreateAt, maxPostSize); err == nil { - t.Fatal("Should have failed due to missing required property.") - } + err = validateReplyImportData(&data, parentCreateAt, maxPostSize) + require.NotNil(t, err, "Should have failed due to missing required property.") data = ReplyImportData{ User: ptrStr("username"), Message: ptrStr("message"), } - if err := validateReplyImportData(&data, parentCreateAt, maxPostSize); err == nil { - t.Fatal("Should have failed due to missing required property.") - } + err = validateReplyImportData(&data, parentCreateAt, maxPostSize) + require.NotNil(t, err, "Should have failed due to missing required property.") // Test with invalid message. data = ReplyImportData{ @@ -927,9 +834,8 @@ func TestImportValidateReplyImportData(t *testing.T) { Message: ptrStr(strings.Repeat("0", maxPostSize+1)), CreateAt: ptrInt64(model.GetMillis()), } - if err := validateReplyImportData(&data, parentCreateAt, maxPostSize); err == nil { - t.Fatal("Should have failed due to too long message.") - } + err = validateReplyImportData(&data, parentCreateAt, maxPostSize) + require.NotNil(t, err, "Should have failed due to too long message.") // Test with invalid CreateAt data = ReplyImportData{ @@ -937,18 +843,16 @@ func TestImportValidateReplyImportData(t *testing.T) { Message: ptrStr("message"), CreateAt: ptrInt64(0), } - if err := validateReplyImportData(&data, parentCreateAt, maxPostSize); err == nil { - t.Fatal("Should have failed due to 0 create-at value.") - } + err = validateReplyImportData(&data, parentCreateAt, maxPostSize) + require.NotNil(t, err, "Should have failed due to 0 create-at value.") data = ReplyImportData{ User: ptrStr("username"), Message: ptrStr("message"), CreateAt: ptrInt64(parentCreateAt - 100), } - if err := validateReplyImportData(&data, parentCreateAt, maxPostSize); err == nil { - t.Fatal("Should have failed due parent with newer create-at value.") - } + err = validateReplyImportData(&data, parentCreateAt, maxPostSize) + require.NotNil(t, err, "Should have failed due parent with newer create-at value.") } func TestImportValidatePostImportData(t *testing.T) { @@ -962,9 +866,8 @@ func TestImportValidatePostImportData(t *testing.T) { Message: ptrStr("message"), CreateAt: ptrInt64(model.GetMillis()), } - if err := validatePostImportData(&data, maxPostSize); err != nil { - t.Fatal("Validation failed but should have been valid.") - } + err := validatePostImportData(&data, maxPostSize) + require.Nil(t, err, "Validation failed but should have been valid.") // Test with missing required properties. data = PostImportData{ @@ -973,9 +876,8 @@ func TestImportValidatePostImportData(t *testing.T) { Message: ptrStr("message"), CreateAt: ptrInt64(model.GetMillis()), } - if err := validatePostImportData(&data, maxPostSize); err == nil { - t.Fatal("Should have failed due to missing required property.") - } + err = validatePostImportData(&data, maxPostSize) + require.NotNil(t, err, "Should have failed due to missing required property.") data = PostImportData{ Team: ptrStr("teamname"), @@ -983,9 +885,8 @@ func TestImportValidatePostImportData(t *testing.T) { Message: ptrStr("message"), CreateAt: ptrInt64(model.GetMillis()), } - if err := validatePostImportData(&data, maxPostSize); err == nil { - t.Fatal("Should have failed due to missing required property.") - } + err = validatePostImportData(&data, maxPostSize) + require.NotNil(t, err, "Should have failed due to missing required property.") data = PostImportData{ Team: ptrStr("teamname"), @@ -993,9 +894,8 @@ func TestImportValidatePostImportData(t *testing.T) { Message: ptrStr("message"), CreateAt: ptrInt64(model.GetMillis()), } - if err := validatePostImportData(&data, maxPostSize); err == nil { - t.Fatal("Should have failed due to missing required property.") - } + err = validatePostImportData(&data, maxPostSize) + require.NotNil(t, err, "Should have failed due to missing required property.") data = PostImportData{ Team: ptrStr("teamname"), @@ -1003,9 +903,8 @@ func TestImportValidatePostImportData(t *testing.T) { User: ptrStr("username"), CreateAt: ptrInt64(model.GetMillis()), } - if err := validatePostImportData(&data, maxPostSize); err == nil { - t.Fatal("Should have failed due to missing required property.") - } + err = validatePostImportData(&data, maxPostSize) + require.NotNil(t, err, "Should have failed due to missing required property.") data = PostImportData{ Team: ptrStr("teamname"), @@ -1013,9 +912,8 @@ func TestImportValidatePostImportData(t *testing.T) { User: ptrStr("username"), Message: ptrStr("message"), } - if err := validatePostImportData(&data, maxPostSize); err == nil { - t.Fatal("Should have failed due to missing required property.") - } + err = validatePostImportData(&data, maxPostSize) + require.NotNil(t, err, "Should have failed due to missing required property.") // Test with invalid message. data = PostImportData{ @@ -1025,9 +923,8 @@ func TestImportValidatePostImportData(t *testing.T) { Message: ptrStr(strings.Repeat("0", maxPostSize+1)), CreateAt: ptrInt64(model.GetMillis()), } - if err := validatePostImportData(&data, maxPostSize); err == nil { - t.Fatal("Should have failed due to too long message.") - } + err = validatePostImportData(&data, maxPostSize) + require.NotNil(t, err, "Should have failed due to too long message.") // Test with invalid CreateAt data = PostImportData{ @@ -1037,9 +934,8 @@ func TestImportValidatePostImportData(t *testing.T) { Message: ptrStr("message"), CreateAt: ptrInt64(0), } - if err := validatePostImportData(&data, maxPostSize); err == nil { - t.Fatal("Should have failed due to 0 create-at value.") - } + err = validatePostImportData(&data, maxPostSize) + require.NotNil(t, err, "Should have failed due to 0 create-at value.") // Test with valid all optional parameters. reactions := []ReactionImportData{ReactionImportData{ @@ -1047,11 +943,13 @@ func TestImportValidatePostImportData(t *testing.T) { EmojiName: ptrStr("emoji"), CreateAt: ptrInt64(model.GetMillis()), }} + replies := []ReplyImportData{ReplyImportData{ User: ptrStr("username"), Message: ptrStr("message"), CreateAt: ptrInt64(model.GetMillis()), }} + data = PostImportData{ Team: ptrStr("teamname"), Channel: ptrStr("channelname"), @@ -1061,9 +959,8 @@ func TestImportValidatePostImportData(t *testing.T) { Reactions: &reactions, Replies: &replies, } - if err := validatePostImportData(&data, maxPostSize); err != nil { - t.Fatal("Should have succeeded.") - } + err = validatePostImportData(&data, maxPostSize) + require.Nil(t, err, "Should have succeeded.") } func TestImportValidateDirectChannelImportData(t *testing.T) { @@ -1075,9 +972,8 @@ func TestImportValidateDirectChannelImportData(t *testing.T) { model.NewId(), }, } - if err := validateDirectChannelImportData(&data); err != nil { - t.Fatal("Validation failed but should have been valid.") - } + err := validateDirectChannelImportData(&data) + require.Nil(t, err, "Validation failed but should have been valid.") // Test with valid number of members for group message. data = DirectChannelImportData{ @@ -1087,9 +983,8 @@ func TestImportValidateDirectChannelImportData(t *testing.T) { model.NewId(), }, } - if err := validateDirectChannelImportData(&data); err != nil { - t.Fatal("Validation failed but should have been valid.") - } + err = validateDirectChannelImportData(&data) + require.Nil(t, err, "Validation failed but should have been valid.") // Test with all the combinations of optional parameters. data = DirectChannelImportData{ @@ -1099,32 +994,28 @@ func TestImportValidateDirectChannelImportData(t *testing.T) { }, Header: ptrStr("Channel Header Here"), } - if err := validateDirectChannelImportData(&data); err != nil { - t.Fatal("Should have succeeded with valid optional properties.") - } + err = validateDirectChannelImportData(&data) + require.Nil(t, err, "Should have succeeded with valid optional properties.") // Test with invalid Header. data.Header = ptrStr(strings.Repeat("abcdefghij ", 103)) - if err := validateDirectChannelImportData(&data); err == nil { - t.Fatal("Should have failed due to too long header.") - } + err = validateDirectChannelImportData(&data) + require.NotNil(t, err, "Should have failed due to too long header.") // Test with different combinations of invalid member counts. data = DirectChannelImportData{ Members: &[]string{}, } - if err := validateDirectChannelImportData(&data); err == nil { - t.Fatal("Validation should have failed due to invalid number of members.") - } + err = validateDirectChannelImportData(&data) + require.NotNil(t, err, "Validation should have failed due to invalid number of members.") data = DirectChannelImportData{ Members: &[]string{ model.NewId(), }, } - if err := validateDirectChannelImportData(&data); err == nil { - t.Fatal("Validation should have failed due to invalid number of members.") - } + err = validateDirectChannelImportData(&data) + require.NotNil(t, err, "Validation should have failed due to invalid number of members.") data = DirectChannelImportData{ Members: &[]string{ @@ -1139,9 +1030,8 @@ func TestImportValidateDirectChannelImportData(t *testing.T) { model.NewId(), }, } - if err := validateDirectChannelImportData(&data); err == nil { - t.Fatal("Validation should have failed due to invalid number of members.") - } + err = validateDirectChannelImportData(&data) + require.NotNil(t, err, "Validation should have failed due to invalid number of members.") // Test with invalid FavoritedBy member1 := model.NewId() @@ -1156,9 +1046,8 @@ func TestImportValidateDirectChannelImportData(t *testing.T) { model.NewId(), }, } - if err := validateDirectChannelImportData(&data); err == nil { - t.Fatal("Validation should have failed due to non-member favorited.") - } + err = validateDirectChannelImportData(&data) + require.NotNil(t, err, "Validation should have failed due to non-member favorited.") // Test with valid FavoritedBy data = DirectChannelImportData{ @@ -1171,9 +1060,8 @@ func TestImportValidateDirectChannelImportData(t *testing.T) { member2, }, } - if err := validateDirectChannelImportData(&data); err != nil { - t.Fatal(err) - } + err = validateDirectChannelImportData(&data) + require.Nil(t, err, "Validation should succeed with valid favorited member") } func TestImportValidateDirectPostImportData(t *testing.T) { @@ -1189,9 +1077,8 @@ func TestImportValidateDirectPostImportData(t *testing.T) { Message: ptrStr("message"), CreateAt: ptrInt64(model.GetMillis()), } - if err := validateDirectPostImportData(&data, maxPostSize); err != nil { - t.Fatal("Validation failed but should have been valid.") - } + err := validateDirectPostImportData(&data, maxPostSize) + require.Nil(t, err, "Validation failed but should have been valid.") // Test with missing required properties. data = DirectPostImportData{ @@ -1199,9 +1086,8 @@ func TestImportValidateDirectPostImportData(t *testing.T) { Message: ptrStr("message"), CreateAt: ptrInt64(model.GetMillis()), } - if err := validateDirectPostImportData(&data, maxPostSize); err == nil { - t.Fatal("Should have failed due to missing required property.") - } + err = validateDirectPostImportData(&data, maxPostSize) + require.NotNil(t, err, "Should have failed due to missing required property.") data = DirectPostImportData{ ChannelMembers: &[]string{ @@ -1211,9 +1097,8 @@ func TestImportValidateDirectPostImportData(t *testing.T) { Message: ptrStr("message"), CreateAt: ptrInt64(model.GetMillis()), } - if err := validateDirectPostImportData(&data, maxPostSize); err == nil { - t.Fatal("Should have failed due to missing required property.") - } + err = validateDirectPostImportData(&data, maxPostSize) + require.NotNil(t, err, "Should have failed due to missing required property.") data = DirectPostImportData{ ChannelMembers: &[]string{ @@ -1223,9 +1108,8 @@ func TestImportValidateDirectPostImportData(t *testing.T) { User: ptrStr("username"), CreateAt: ptrInt64(model.GetMillis()), } - if err := validateDirectPostImportData(&data, maxPostSize); err == nil { - t.Fatal("Should have failed due to missing required property.") - } + err = validateDirectPostImportData(&data, maxPostSize) + require.NotNil(t, err, "Should have failed due to missing required property.") data = DirectPostImportData{ ChannelMembers: &[]string{ @@ -1235,9 +1119,8 @@ func TestImportValidateDirectPostImportData(t *testing.T) { User: ptrStr("username"), Message: ptrStr("message"), } - if err := validateDirectPostImportData(&data, maxPostSize); err == nil { - t.Fatal("Should have failed due to missing required property.") - } + err = validateDirectPostImportData(&data, maxPostSize) + require.NotNil(t, err, "Should have failed due to missing required property.") // Test with invalid numbers of channel members. data = DirectPostImportData{ @@ -1246,9 +1129,8 @@ func TestImportValidateDirectPostImportData(t *testing.T) { Message: ptrStr("message"), CreateAt: ptrInt64(model.GetMillis()), } - if err := validateDirectPostImportData(&data, maxPostSize); err == nil { - t.Fatal("Should have failed due to unsuitable number of members.") - } + err = validateDirectPostImportData(&data, maxPostSize) + require.NotNil(t, err, "Should have failed due to unsuitable number of members.") data = DirectPostImportData{ ChannelMembers: &[]string{ @@ -1258,9 +1140,8 @@ func TestImportValidateDirectPostImportData(t *testing.T) { Message: ptrStr("message"), CreateAt: ptrInt64(model.GetMillis()), } - if err := validateDirectPostImportData(&data, maxPostSize); err == nil { - t.Fatal("Should have failed due to unsuitable number of members.") - } + err = validateDirectPostImportData(&data, maxPostSize) + require.NotNil(t, err, "Should have failed due to unsuitable number of members.") data = DirectPostImportData{ ChannelMembers: &[]string{ @@ -1279,9 +1160,8 @@ func TestImportValidateDirectPostImportData(t *testing.T) { Message: ptrStr("message"), CreateAt: ptrInt64(model.GetMillis()), } - if err := validateDirectPostImportData(&data, maxPostSize); err == nil { - t.Fatal("Should have failed due to unsuitable number of members.") - } + err = validateDirectPostImportData(&data, maxPostSize) + require.NotNil(t, err, "Should have failed due to unsuitable number of members.") // Test with group message number of members. data = DirectPostImportData{ @@ -1294,9 +1174,8 @@ func TestImportValidateDirectPostImportData(t *testing.T) { Message: ptrStr("message"), CreateAt: ptrInt64(model.GetMillis()), } - if err := validateDirectPostImportData(&data, maxPostSize); err != nil { - t.Fatal("Validation failed but should have been valid.") - } + err = validateDirectPostImportData(&data, maxPostSize) + require.Nil(t, err, "Validation failed but should have been valid.") // Test with invalid message. data = DirectPostImportData{ @@ -1308,9 +1187,8 @@ func TestImportValidateDirectPostImportData(t *testing.T) { Message: ptrStr(strings.Repeat("0", maxPostSize+1)), CreateAt: ptrInt64(model.GetMillis()), } - if err := validateDirectPostImportData(&data, maxPostSize); err == nil { - t.Fatal("Should have failed due to too long message.") - } + err = validateDirectPostImportData(&data, maxPostSize) + require.NotNil(t, err, "Should have failed due to too long message.") // Test with invalid CreateAt data = DirectPostImportData{ @@ -1322,9 +1200,8 @@ func TestImportValidateDirectPostImportData(t *testing.T) { Message: ptrStr("message"), CreateAt: ptrInt64(0), } - if err := validateDirectPostImportData(&data, maxPostSize); err == nil { - t.Fatal("Should have failed due to 0 create-at value.") - } + err = validateDirectPostImportData(&data, maxPostSize) + require.NotNil(t, err, "Should have failed due to 0 create-at value.") // Test with invalid FlaggedBy member1 := model.NewId() @@ -1342,9 +1219,8 @@ func TestImportValidateDirectPostImportData(t *testing.T) { Message: ptrStr("message"), CreateAt: ptrInt64(model.GetMillis()), } - if err := validateDirectPostImportData(&data, maxPostSize); err == nil { - t.Fatal("Validation should have failed due to non-member flagged.") - } + err = validateDirectPostImportData(&data, maxPostSize) + require.NotNil(t, err, "Validation should have failed due to non-member flagged.") // Test with valid FlaggedBy data = DirectPostImportData{ @@ -1360,9 +1236,8 @@ func TestImportValidateDirectPostImportData(t *testing.T) { Message: ptrStr("message"), CreateAt: ptrInt64(model.GetMillis()), } - if err := validateDirectPostImportData(&data, maxPostSize); err != nil { - t.Fatal(err) - } + err = validateDirectPostImportData(&data, maxPostSize) + require.Nil(t, err, "Validation should succeed with post flagged by members") // Test with valid all optional parameters. reactions := []ReactionImportData{ReactionImportData{ @@ -1370,11 +1245,13 @@ func TestImportValidateDirectPostImportData(t *testing.T) { EmojiName: ptrStr("emoji"), CreateAt: ptrInt64(model.GetMillis()), }} + replies := []ReplyImportData{ReplyImportData{ User: ptrStr("username"), Message: ptrStr("message"), CreateAt: ptrInt64(model.GetMillis()), }} + data = DirectPostImportData{ ChannelMembers: &[]string{ member1, @@ -1391,9 +1268,8 @@ func TestImportValidateDirectPostImportData(t *testing.T) { Replies: &replies, } - if err := validateDirectPostImportData(&data, maxPostSize); err != nil { - t.Fatal(err) - } + err = validateDirectPostImportData(&data, maxPostSize) + require.Nil(t, err, "Validation should succeed with valid optional parameters") } func TestImportValidateEmojiImportData(t *testing.T) { diff --git a/app/login_test.go b/app/login_test.go index 585865753e..7cd9523f83 100644 --- a/app/login_test.go +++ b/app/login_test.go @@ -6,6 +6,8 @@ package app import ( "net/http" "testing" + + "github.com/stretchr/testify/require" ) func TestCheckForClientSideCert(t *testing.T) { @@ -30,8 +32,6 @@ func TestCheckForClientSideCert(t *testing.T) { _, _, actualEmail := th.App.CheckForClientSideCert(r) - if actualEmail != tt.expectedEmail { - t.Fatalf("CheckForClientSideCert(%v): expected %v, actual %v", tt.subject, tt.expectedEmail, actualEmail) - } + require.Equal(t, actualEmail, tt.expectedEmail, "CheckForClientSideCert(%v): expected %v, actual %v", tt.subject, tt.expectedEmail, actualEmail) } } diff --git a/app/notification_email_test.go b/app/notification_email_test.go index b7d1b0a133..0429934dc6 100644 --- a/app/notification_email_test.go +++ b/app/notification_email_test.go @@ -11,6 +11,7 @@ import ( "time" "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" "github.com/mattermost/mattermost-server/model" "github.com/mattermost/mattermost-server/services/timezones" @@ -28,9 +29,7 @@ func TestGetDirectMessageNotificationEmailSubject(t *testing.T) { } translateFunc := utils.GetUserTranslations("en") subject := getDirectMessageNotificationEmailSubject(user, post, translateFunc, "http://localhost:8065", "@sender", true) - if !strings.HasPrefix(subject, expectedPrefix) { - t.Fatal("Expected subject line prefix '" + expectedPrefix + "', got " + subject) - } + require.Regexp(t, regexp.MustCompile("^"+regexp.QuoteMeta(expectedPrefix)), subject, fmt.Sprintf("Expected subject line prefix '%s', got %s", expectedPrefix, subject)) } func TestGetGroupMessageNotificationEmailSubjectFull(t *testing.T) { @@ -45,9 +44,7 @@ func TestGetGroupMessageNotificationEmailSubjectFull(t *testing.T) { translateFunc := utils.GetUserTranslations("en") emailNotificationContentsType := model.EMAIL_NOTIFICATION_CONTENTS_FULL subject := getGroupMessageNotificationEmailSubject(user, post, translateFunc, "http://localhost:8065", "sender", emailNotificationContentsType, true) - if !strings.HasPrefix(subject, expectedPrefix) { - t.Fatal("Expected subject line prefix '" + expectedPrefix + "', got " + subject) - } + require.Regexp(t, regexp.MustCompile("^"+regexp.QuoteMeta(expectedPrefix)), subject, fmt.Sprintf("Expected subject line prefix '%s', got %s", expectedPrefix, subject)) } func TestGetGroupMessageNotificationEmailSubjectGeneric(t *testing.T) { @@ -62,9 +59,7 @@ func TestGetGroupMessageNotificationEmailSubjectGeneric(t *testing.T) { translateFunc := utils.GetUserTranslations("en") emailNotificationContentsType := model.EMAIL_NOTIFICATION_CONTENTS_GENERIC subject := getGroupMessageNotificationEmailSubject(user, post, translateFunc, "http://localhost:8065", "sender", emailNotificationContentsType, true) - if !strings.HasPrefix(subject, expectedPrefix) { - t.Fatal("Expected subject line prefix '" + expectedPrefix + "', got " + subject) - } + require.Regexp(t, regexp.MustCompile("^"+regexp.QuoteMeta(expectedPrefix)), subject, fmt.Sprintf("Expected subject line prefix '%s', got %s", expectedPrefix, subject)) } func TestGetNotificationEmailSubject(t *testing.T) { @@ -78,9 +73,7 @@ func TestGetNotificationEmailSubject(t *testing.T) { } translateFunc := utils.GetUserTranslations("en") subject := getNotificationEmailSubject(user, post, translateFunc, "http://localhost:8065", "team", true) - if !strings.HasPrefix(subject, expectedPrefix) { - t.Fatal("Expected subject line prefix '" + expectedPrefix + "', got " + subject) - } + require.Regexp(t, regexp.MustCompile("^"+regexp.QuoteMeta(expectedPrefix)), subject, fmt.Sprintf("Expected subject line prefix '%s', got %s", expectedPrefix, subject)) } func TestGetNotificationEmailBodyFullNotificationPublicChannel(t *testing.T) { @@ -103,21 +96,11 @@ func TestGetNotificationEmailBodyFullNotificationPublicChannel(t *testing.T) { translateFunc := utils.GetUserTranslations("en") body := th.App.getNotificationEmailBody(recipient, post, channel, channelName, senderName, teamName, teamURL, emailNotificationContentsType, true, translateFunc) - if !strings.Contains(body, "You have a new notification.") { - t.Fatal("Expected email text 'You have a new notification. Got " + body) - } - if !strings.Contains(body, "Channel: "+channel.DisplayName) { - t.Fatal("Expected email text 'Channel: " + channel.DisplayName + "'. Got " + body) - } - if !strings.Contains(body, senderName+" - ") { - t.Fatal("Expected email text '" + senderName + " - '. Got " + body) - } - if !strings.Contains(body, post.Message) { - t.Fatal("Expected email text '" + post.Message + "'. Got " + body) - } - if !strings.Contains(body, teamURL) { - t.Fatal("Expected email text '" + teamURL + "'. Got " + body) - } + require.Contains(t, body, "You have a new notification.", fmt.Sprintf("Expected email text 'You have a new notification. Got %s", body)) + require.Contains(t, body, "Channel: "+channel.DisplayName, "Expected email text 'Channel: %s'. Got %s", channel.DisplayName, body) + require.Contains(t, body, senderName+" - ", fmt.Sprintf("Expected email text '%s - '. Got %s", senderName, body)) + require.Contains(t, body, post.Message, fmt.Sprintf("Expected email text '%s'. Got %s", post.Message, body)) + require.Contains(t, body, teamURL, fmt.Sprintf("Expected email text '%s'. Got %s", teamURL, body)) } func TestGetNotificationEmailBodyFullNotificationGroupChannel(t *testing.T) { @@ -140,21 +123,11 @@ func TestGetNotificationEmailBodyFullNotificationGroupChannel(t *testing.T) { translateFunc := utils.GetUserTranslations("en") body := th.App.getNotificationEmailBody(recipient, post, channel, channelName, senderName, teamName, teamURL, emailNotificationContentsType, true, translateFunc) - if !strings.Contains(body, "You have a new Group Message.") { - t.Fatal("Expected email text 'You have a new Group Message. Got " + body) - } - if !strings.Contains(body, "Channel: ChannelName") { - t.Fatal("Expected email text 'Channel: ChannelName'. Got " + body) - } - if !strings.Contains(body, senderName+" - ") { - t.Fatal("Expected email text '" + senderName + " - '. Got " + body) - } - if !strings.Contains(body, post.Message) { - t.Fatal("Expected email text '" + post.Message + "'. Got " + body) - } - if !strings.Contains(body, teamURL) { - t.Fatal("Expected email text '" + teamURL + "'. Got " + body) - } + require.Contains(t, body, "You have a new Group Message.", fmt.Sprintf("Expected email text 'You have a new Group Message. Got "+body)) + require.Contains(t, body, "Channel: ChannelName", fmt.Sprintf("Expected email text 'Channel: ChannelName'. Got %s", body)) + require.Contains(t, body, senderName+" - ", fmt.Sprintf("Expected email text '%s - '. Got %s", senderName, body)) + require.Contains(t, body, post.Message, fmt.Sprintf("Expected email text '%s'. Got %s", post.Message, body)) + require.Contains(t, body, teamURL, fmt.Sprintf("Expected email text '%s'. Got %s", teamURL, body)) } func TestGetNotificationEmailBodyFullNotificationPrivateChannel(t *testing.T) { @@ -177,21 +150,11 @@ func TestGetNotificationEmailBodyFullNotificationPrivateChannel(t *testing.T) { translateFunc := utils.GetUserTranslations("en") body := th.App.getNotificationEmailBody(recipient, post, channel, channelName, senderName, teamName, teamURL, emailNotificationContentsType, true, translateFunc) - if !strings.Contains(body, "You have a new notification.") { - t.Fatal("Expected email text 'You have a new notification. Got " + body) - } - if !strings.Contains(body, "Channel: "+channel.DisplayName) { - t.Fatal("Expected email text 'Channel: " + channel.DisplayName + "'. Got " + body) - } - if !strings.Contains(body, senderName+" - ") { - t.Fatal("Expected email text '" + senderName + " - '. Got " + body) - } - if !strings.Contains(body, post.Message) { - t.Fatal("Expected email text '" + post.Message + "'. Got " + body) - } - if !strings.Contains(body, teamURL) { - t.Fatal("Expected email text '" + teamURL + "'. Got " + body) - } + require.Contains(t, body, "You have a new notification.", fmt.Sprintf("Expected email text 'You have a new notification. Got "+body)) + require.Contains(t, body, "Channel: "+channel.DisplayName, fmt.Sprintf("Expected email text 'Channel: "+channel.DisplayName+"'. Got "+body)) + require.Contains(t, body, senderName+" - ", fmt.Sprintf("Expected email text '%s - '. Got %s", senderName, body)) + require.Contains(t, body, post.Message, fmt.Sprintf("Expected email text '%s'. Got %s", post.Message, body)) + require.Contains(t, body, teamURL, fmt.Sprintf("Expected email text '%s'. Got %s", teamURL, body)) } func TestGetNotificationEmailBodyFullNotificationDirectChannel(t *testing.T) { @@ -214,18 +177,10 @@ func TestGetNotificationEmailBodyFullNotificationDirectChannel(t *testing.T) { translateFunc := utils.GetUserTranslations("en") body := th.App.getNotificationEmailBody(recipient, post, channel, channelName, senderName, teamName, teamURL, emailNotificationContentsType, true, translateFunc) - if !strings.Contains(body, "You have a new Direct Message.") { - t.Fatal("Expected email text 'You have a new Direct Message. Got " + body) - } - if !strings.Contains(body, senderName+" - ") { - t.Fatal("Expected email text '" + senderName + " - '. Got " + body) - } - if !strings.Contains(body, post.Message) { - t.Fatal("Expected email text '" + post.Message + "'. Got " + body) - } - if !strings.Contains(body, teamURL) { - t.Fatal("Expected email text '" + teamURL + "'. Got " + body) - } + require.Contains(t, body, "You have a new Direct Message.", fmt.Sprintf("Expected email text 'You have a new Direct Message. Got "+body)) + require.Contains(t, body, senderName+" - ", fmt.Sprintf("Expected email text '%s - '. Got %s", senderName, body)) + require.Contains(t, body, post.Message, fmt.Sprintf("Expected email text '%s'. Got %s", post.Message, body)) + require.Contains(t, body, teamURL, fmt.Sprintf("Expected email text '%s'. Got %s", teamURL, body)) } func TestGetNotificationEmailBodyFullNotificationLocaleTimeWithTimezone(t *testing.T) { @@ -254,9 +209,7 @@ func TestGetNotificationEmailBodyFullNotificationLocaleTimeWithTimezone(t *testi body := th.App.getNotificationEmailBody(recipient, post, channel, channelName, senderName, teamName, teamURL, emailNotificationContentsType, false, translateFunc) r, _ := regexp.Compile("E([S|D]+)T") zone := r.FindString(body) - if !strings.Contains(body, "sender - 9:43 AM "+zone+", April 25") { - t.Fatal("Expected email text 'sender - 9:43 AM " + zone + ", April 25'. Got " + body) - } + require.Contains(t, body, "sender - 9:43 AM "+zone+", April 25", fmt.Sprintf("Expected email text 'sender - 9:43 AM %s, April 25'. Got %s", zone, body)) } func TestGetNotificationEmailBodyFullNotificationLocaleTimeNoTimezone(t *testing.T) { @@ -296,9 +249,7 @@ func TestGetNotificationEmailBodyFullNotificationLocaleTimeNoTimezone(t *testing body := th.App.getNotificationEmailBody(recipient, post, channel, channelName, senderName, teamName, teamURL, emailNotificationContentsType, true, translateFunc) postTimeLine := fmt.Sprintf("sender - %s:%s %s, %s %s", formattedTime.Hour, formattedTime.Minute, formattedTime.TimeZone, formattedTime.Month, formattedTime.Day) - if !strings.Contains(body, postTimeLine) { - t.Fatal("Expected email text '" + postTimeLine + " '. Got " + body) - } + require.Contains(t, body, postTimeLine, fmt.Sprintf("Expected email text '%s'. Got %s", postTimeLine, body)) } func TestGetNotificationEmailBodyFullNotificationLocaleTime12Hour(t *testing.T) { @@ -325,12 +276,8 @@ func TestGetNotificationEmailBodyFullNotificationLocaleTime12Hour(t *testing.T) translateFunc := utils.GetUserTranslations("en") body := th.App.getNotificationEmailBody(recipient, post, channel, channelName, senderName, teamName, teamURL, emailNotificationContentsType, false, translateFunc) - if !strings.Contains(body, "sender - 2:30 PM") { - t.Fatal("Expected email text 'sender - 2:30 PM'. Got " + body) - } - if !strings.Contains(body, "April 25") { - t.Fatal("Expected email text 'April 25'. Got " + body) - } + require.Contains(t, body, "sender - 2:30 PM", fmt.Sprintf("Expected email text 'sender - 2:30 PM'. Got %s", body)) + require.Contains(t, body, "April 25", fmt.Sprintf("Expected email text 'April 25'. Got %s", body)) } func TestGetNotificationEmailBodyFullNotificationLocaleTime24Hour(t *testing.T) { @@ -357,12 +304,8 @@ func TestGetNotificationEmailBodyFullNotificationLocaleTime24Hour(t *testing.T) translateFunc := utils.GetUserTranslations("en") body := th.App.getNotificationEmailBody(recipient, post, channel, channelName, senderName, teamName, teamURL, emailNotificationContentsType, true, translateFunc) - if !strings.Contains(body, "sender - 14:30") { - t.Fatal("Expected email text 'sender - 14:30'. Got " + body) - } - if !strings.Contains(body, "April 25") { - t.Fatal("Expected email text 'April 25'. Got " + body) - } + require.Contains(t, body, "sender - 14:30", fmt.Sprintf("Expected email text 'sender - 14:30'. Got %s", body)) + require.Contains(t, body, "April 25", fmt.Sprintf("Expected email text 'April 25'. Got %s", body)) } // from here @@ -386,18 +329,10 @@ func TestGetNotificationEmailBodyGenericNotificationPublicChannel(t *testing.T) translateFunc := utils.GetUserTranslations("en") body := th.App.getNotificationEmailBody(recipient, post, channel, channelName, senderName, teamName, teamURL, emailNotificationContentsType, true, translateFunc) - if !strings.Contains(body, "You have a new notification from "+senderName) { - t.Fatal("Expected email text 'You have a new notification from " + senderName + "'. Got " + body) - } - if strings.Contains(body, "Channel: "+channel.DisplayName) { - t.Fatal("Did not expect email text 'Channel: " + channel.DisplayName + "'. Got " + body) - } - if strings.Contains(body, post.Message) { - t.Fatal("Did not expect email text '" + post.Message + "'. Got " + body) - } - if !strings.Contains(body, teamURL) { - t.Fatal("Expected email text '" + teamURL + "'. Got " + body) - } + require.Contains(t, body, "You have a new notification from "+senderName, fmt.Sprintf("Expected email text 'You have a new notification from %s'. Got %s", senderName, body)) + require.False(t, strings.Contains(body, "Channel: "+channel.DisplayName), fmt.Sprintf("Did not expect email text 'CHANNEL: %s'. Got %s", channel.DisplayName, body)) + require.False(t, strings.Contains(body, post.Message), fmt.Sprintf("Did not expect email text '%s'. Got %s", post.Message, body)) + require.Contains(t, body, teamURL, fmt.Sprintf("Expected email text '%s'. Got %s", teamURL, body)) } func TestGetNotificationEmailBodyGenericNotificationGroupChannel(t *testing.T) { @@ -420,18 +355,10 @@ func TestGetNotificationEmailBodyGenericNotificationGroupChannel(t *testing.T) { translateFunc := utils.GetUserTranslations("en") body := th.App.getNotificationEmailBody(recipient, post, channel, channelName, senderName, teamName, teamURL, emailNotificationContentsType, true, translateFunc) - if !strings.Contains(body, "You have a new Group Message from "+senderName) { - t.Fatal("Expected email text 'You have a new Group Message from " + senderName + "'. Got " + body) - } - if strings.Contains(body, "CHANNEL: "+channel.DisplayName) { - t.Fatal("Did not expect email text 'CHANNEL: " + channel.DisplayName + "'. Got " + body) - } - if strings.Contains(body, post.Message) { - t.Fatal("Did not expect email text '" + post.Message + "'. Got " + body) - } - if !strings.Contains(body, teamURL) { - t.Fatal("Expected email text '" + teamURL + "'. Got " + body) - } + require.Contains(t, body, "You have a new Group Message from "+senderName, fmt.Sprintf("Expected email text 'You have a new Group Message from %s'. Got %s", senderName, body)) + require.False(t, strings.Contains(body, "CHANNEL: "+channel.DisplayName), fmt.Sprintf("Did not expect email text 'CHANNEL: %s'. Got %s", channel.DisplayName, body)) + require.False(t, strings.Contains(body, post.Message), fmt.Sprintf("Did not expect email text '%s'. Got %s", post.Message, body)) + require.Contains(t, body, teamURL, fmt.Sprintf("Expected email text '%s'. Got %s", teamURL, body)) } func TestGetNotificationEmailBodyGenericNotificationPrivateChannel(t *testing.T) { @@ -454,18 +381,10 @@ func TestGetNotificationEmailBodyGenericNotificationPrivateChannel(t *testing.T) translateFunc := utils.GetUserTranslations("en") body := th.App.getNotificationEmailBody(recipient, post, channel, channelName, senderName, teamName, teamURL, emailNotificationContentsType, true, translateFunc) - if !strings.Contains(body, "You have a new notification from "+senderName) { - t.Fatal("Expected email text 'You have a new notification from " + senderName + "'. Got " + body) - } - if strings.Contains(body, "CHANNEL: "+channel.DisplayName) { - t.Fatal("Did not expect email text 'CHANNEL: " + channel.DisplayName + "'. Got " + body) - } - if strings.Contains(body, post.Message) { - t.Fatal("Did not expect email text '" + post.Message + "'. Got " + body) - } - if !strings.Contains(body, teamURL) { - t.Fatal("Expected email text '" + teamURL + "'. Got " + body) - } + require.Contains(t, body, "You have a new notification from "+senderName, fmt.Sprintf("Expected email text 'You have a new notification from %s'. Got %s", senderName, body)) + require.False(t, strings.Contains(body, "CHANNEL: "+channel.DisplayName), fmt.Sprintf("Did not expect email text 'CHANNEL: %s'. Got %s", channel.DisplayName, body)) + require.False(t, strings.Contains(body, post.Message), fmt.Sprintf("Did not expect email text '%s'. Got %s", post.Message, body)) + require.Contains(t, body, teamURL, fmt.Sprintf("Expected email text '%s'. Got %s", teamURL, body)) } func TestGetNotificationEmailBodyGenericNotificationDirectChannel(t *testing.T) { @@ -488,18 +407,10 @@ func TestGetNotificationEmailBodyGenericNotificationDirectChannel(t *testing.T) translateFunc := utils.GetUserTranslations("en") body := th.App.getNotificationEmailBody(recipient, post, channel, channelName, senderName, teamName, teamURL, emailNotificationContentsType, true, translateFunc) - if !strings.Contains(body, "You have a new Direct Message from "+senderName) { - t.Fatal("Expected email text 'You have a new Direct Message from " + senderName + "'. Got " + body) - } - if strings.Contains(body, "CHANNEL: "+channel.DisplayName) { - t.Fatal("Did not expect email text 'CHANNEL: " + channel.DisplayName + "'. Got " + body) - } - if strings.Contains(body, post.Message) { - t.Fatal("Did not expect email text '" + post.Message + "'. Got " + body) - } - if !strings.Contains(body, teamURL) { - t.Fatal("Expected email text '" + teamURL + "'. Got " + body) - } + require.Contains(t, body, "You have a new Direct Message from "+senderName, fmt.Sprintf("Expected email text 'You have a new Direct Message from "+senderName+"'. Got "+body)) + require.False(t, strings.Contains(body, "CHANNEL: "+channel.DisplayName), fmt.Sprintf("Did not expect email text 'CHANNEL: %s'. Got %s", channel.DisplayName, body)) + require.False(t, strings.Contains(body, post.Message), fmt.Sprintf("Did not expect email text '%s'. Got %s", post.Message, body)) + require.Contains(t, body, teamURL, fmt.Sprintf("Expected email text '%s'. Got %s", teamURL, body)) } func TestGetNotificationEmailEscapingChars(t *testing.T) { diff --git a/app/notification_push.go b/app/notification_push.go index 2fc9aa748a..6eaed43f58 100644 --- a/app/notification_push.go +++ b/app/notification_push.go @@ -4,7 +4,6 @@ package app import ( - "fmt" "hash/fnv" "net/http" "strings" @@ -174,7 +173,7 @@ func (a *App) getPushNotificationMessage(postMessage string, explicitMention, ch func (a *App) ClearPushNotificationSync(currentSessionId, userId, channelId string) { sessions, err := a.getMobileAppSessions(userId) if err != nil { - mlog.Error(err.Error()) + mlog.Error("error getting mobile app sessions", mlog.Err(err)) return } @@ -187,7 +186,7 @@ func (a *App) ClearPushNotificationSync(currentSessionId, userId, channelId stri if unreadCount, err := a.Srv.Store.User().GetUnreadCount(userId); err != nil { msg.Badge = 0 - mlog.Error(fmt.Sprint("We could not get the unread message count for the user", userId, err), mlog.String("user_id", userId)) + mlog.Error("We could not get the unread message count for", mlog.String("user_id", userId), mlog.Err(err)) } else { msg.Badge = int(unreadCount) } @@ -267,7 +266,7 @@ func (a *App) pushNotificationWorker(notifications chan PushNotification) { notification.replyToThreadType, ) default: - mlog.Error(fmt.Sprintf("Invalid notification type %v", notification.notificationType)) + mlog.Error("Invalid notification type", mlog.String("notification_type", string(notification.notificationType))) } } } @@ -446,14 +445,14 @@ func (a *App) BuildPushNotificationMessage(post *model.Post, user *model.User, c if user.NotifyProps["push"] == "all" { if unreadCount, err := a.Srv.Store.User().GetAnyUnreadPostCountForChannel(user.Id, channel.Id); err != nil { msg.Badge = 1 - mlog.Error(fmt.Sprint("We could not get the unread message count for the user", user.Id, err), mlog.String("user_id", user.Id)) + mlog.Error("We could not get the unread message count for the user", mlog.String("user_id", user.Id), mlog.Err(err)) } else { msg.Badge = int(unreadCount) } } else { if unreadCount, err := a.Srv.Store.User().GetUnreadCount(user.Id); err != nil { msg.Badge = 1 - mlog.Error(fmt.Sprint("We could not get the unread message count for the user", user.Id, err), mlog.String("user_id", user.Id)) + mlog.Error("We could not get the unread message count for the user", mlog.String("user_id", user.Id), mlog.Err(err)) } else { msg.Badge = int(unreadCount) } diff --git a/app/oauth_test.go b/app/oauth_test.go index 0007835fe1..5392390899 100644 --- a/app/oauth_test.go +++ b/app/oauth_test.go @@ -69,9 +69,8 @@ func TestOAuthRevokeAccessToken(t *testing.T) { th := Setup(t) defer th.TearDown() - if err := th.App.RevokeAccessToken(model.NewRandomString(16)); err == nil { - t.Fatal("Should have failed bad token") - } + err := th.App.RevokeAccessToken(model.NewRandomString(16)) + require.NotNil(t, err, "Should have failed bad token") session := &model.Session{} session.CreateAt = model.GetMillis() @@ -81,9 +80,8 @@ func TestOAuthRevokeAccessToken(t *testing.T) { session.SetExpireInDays(1) session, _ = th.App.CreateSession(session) - if err := th.App.RevokeAccessToken(session.Token); err == nil { - t.Fatal("Should have failed does not have an access token") - } + err = th.App.RevokeAccessToken(session.Token) + require.NotNil(t, err, "Should have failed does not have an access token") accessData := &model.AccessData{} accessData.Token = session.Token @@ -92,12 +90,11 @@ func TestOAuthRevokeAccessToken(t *testing.T) { accessData.ClientId = model.NewId() accessData.ExpiresAt = session.ExpiresAt - _, err := th.App.Srv.Store.OAuth().SaveAccessData(accessData) + _, err = th.App.Srv.Store.OAuth().SaveAccessData(accessData) require.Nil(t, err) - if err = th.App.RevokeAccessToken(accessData.Token); err != nil { - t.Fatal(err) - } + err = th.App.RevokeAccessToken(accessData.Token) + require.Nil(t, err) } func TestOAuthDeleteApp(t *testing.T) { @@ -114,9 +111,7 @@ func TestOAuthDeleteApp(t *testing.T) { var err *model.AppError a1, err = th.App.CreateOAuthApp(a1) - if err != nil { - t.Fatal(err) - } + require.Nil(t, err) session := &model.Session{} session.CreateAt = model.GetMillis() @@ -138,13 +133,11 @@ func TestOAuthDeleteApp(t *testing.T) { _, err = th.App.Srv.Store.OAuth().SaveAccessData(accessData) require.Nil(t, err) - if err = th.App.DeleteOAuthApp(a1.Id); err != nil { - t.Fatal(err) - } + err = th.App.DeleteOAuthApp(a1.Id) + require.Nil(t, err) - if _, err = th.App.GetSession(session.Token); err == nil { - t.Fatal("should not get session from cache or db") - } + _, err = th.App.GetSession(session.Token) + require.NotNil(t, err, "should not get session from cache or db") } func TestAuthorizeOAuthUser(t *testing.T) { diff --git a/app/post_test.go b/app/post_test.go index 5092aa9cd7..1aafc913c0 100644 --- a/app/post_test.go +++ b/app/post_test.go @@ -259,22 +259,17 @@ func TestUpdatePostEditAt(t *testing.T) { *post = *th.BasicPost post.IsPinned = true - if saved, err := th.App.UpdatePost(post, true); err != nil { - t.Fatal(err) - } else if saved.EditAt != post.EditAt { - t.Fatal("shouldn't have updated post.EditAt when pinning post") - - *post = *saved - } + saved, err := th.App.UpdatePost(post, true) + require.Nil(t, err) + assert.Equal(t, saved.EditAt, post.EditAt, "shouldn't have updated post.EditAt when pinning post") + *post = *saved time.Sleep(time.Millisecond * 100) post.Message = model.NewId() - if saved, err := th.App.UpdatePost(post, true); err != nil { - t.Fatal(err) - } else if saved.EditAt == post.EditAt { - t.Fatal("should have updated post.EditAt when updating post message") - } + saved, err = th.App.UpdatePost(post, true) + require.Nil(t, err) + assert.NotEqual(t, saved.EditAt, post.EditAt, "should have updated post.EditAt when updating post message") time.Sleep(time.Millisecond * 200) } @@ -291,25 +286,23 @@ func TestUpdatePostTimeLimit(t *testing.T) { th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.PostEditTimeLimit = -1 }) - if _, err := th.App.UpdatePost(post, true); err != nil { - t.Fatal(err) - } + _, err := th.App.UpdatePost(post, true) + require.Nil(t, err) th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.PostEditTimeLimit = 1000000000 }) post.Message = model.NewId() - if _, err := th.App.UpdatePost(post, true); err != nil { - t.Fatal("should allow you to edit the post") - } + + _, err = th.App.UpdatePost(post, true) + require.Nil(t, err, "should allow you to edit the post") th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.PostEditTimeLimit = 1 }) post.Message = model.NewId() - if _, err := th.App.UpdatePost(post, true); err == nil { - t.Fatal("should fail on update old post") - } + _, err = th.App.UpdatePost(post, true) + require.NotNil(t, err, "should fail on update old post") th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.PostEditTimeLimit = -1 @@ -340,14 +333,11 @@ func TestPostReplyToPostWhereRootPosterLeftChannel(t *testing.T) { userNotInChannel := th.BasicUser rootPost := th.BasicPost - if _, err := th.App.AddUserToChannel(userInChannel, channel); err != nil { - t.Fatal(err) - } - - if err := th.App.RemoveUserFromChannel(userNotInChannel.Id, "", channel); err != nil { - t.Fatal(err) - } + _, err := th.App.AddUserToChannel(userInChannel, channel) + require.Nil(t, err) + err = th.App.RemoveUserFromChannel(userNotInChannel.Id, "", channel) + require.Nil(t, err) replyPost := model.Post{ Message: "asd", ChannelId: channel.Id, @@ -358,9 +348,8 @@ func TestPostReplyToPostWhereRootPosterLeftChannel(t *testing.T) { CreateAt: 0, } - if _, err := th.App.CreatePostAsUser(&replyPost, ""); err != nil { - t.Fatal(err) - } + _, err = th.App.CreatePostAsUser(&replyPost, "") + require.Nil(t, err) } func TestPostAttachPostToChildPost(t *testing.T) { @@ -382,9 +371,7 @@ func TestPostAttachPostToChildPost(t *testing.T) { } res1, err := th.App.CreatePostAsUser(&replyPost1, "") - if err != nil { - t.Fatal(err) - } + require.Nil(t, err) replyPost2 := model.Post{ Message: "reply two", @@ -397,9 +384,7 @@ func TestPostAttachPostToChildPost(t *testing.T) { } _, err = th.App.CreatePostAsUser(&replyPost2, "") - if err.StatusCode != http.StatusBadRequest { - t.Fatal(fmt.Sprintf("Expected BadRequest error, got %v", err)) - } + assert.Equalf(t, err.StatusCode, http.StatusBadRequest, "Expected BadRequest error, got %v", err) replyPost3 := model.Post{ Message: "reply three", @@ -411,9 +396,8 @@ func TestPostAttachPostToChildPost(t *testing.T) { CreateAt: 0, } - if _, err := th.App.CreatePostAsUser(&replyPost3, ""); err != nil { - t.Fatal(err) - } + _, err = th.App.CreatePostAsUser(&replyPost3, "") + assert.Nil(t, err) } func TestPostChannelMentions(t *testing.T) { @@ -429,9 +413,7 @@ func TestPostChannelMentions(t *testing.T) { Type: model.CHANNEL_OPEN, TeamId: th.BasicTeam.Id, }, false) - if err != nil { - t.Fatal(err.Error()) - } + require.Nil(t, err) defer th.App.PermanentDeleteChannel(channelToMention) _, err = th.App.AddUserToChannel(user, channel) @@ -618,14 +600,11 @@ func TestDeletePostWithFileAttachments(t *testing.T) { data := []byte("abcd") info1, err := th.App.DoUploadFile(time.Date(2007, 2, 4, 1, 2, 3, 4, time.Local), teamId, channelId, userId, filename, data) - if err != nil { - t.Fatal(err) - } else { - defer func() { - th.App.Srv.Store.FileInfo().PermanentDelete(info1.Id) - th.App.RemoveFile(info1.Path) - }() - } + require.Nil(t, err) + defer func() { + th.App.Srv.Store.FileInfo().PermanentDelete(info1.Id) + th.App.RemoveFile(info1.Path) + }() post := &model.Post{ Message: "asd", diff --git a/app/user_agent_test.go b/app/user_agent_test.go index e4680bfc93..818ddf4a67 100644 --- a/app/user_agent_test.go +++ b/app/user_agent_test.go @@ -5,6 +5,7 @@ import ( "testing" "github.com/avct/uasurfer" + "github.com/stretchr/testify/assert" ) type testUserAgent struct { @@ -53,9 +54,8 @@ func TestGetPlatformName(t *testing.T) { t.Run(fmt.Sprintf("GetPlatformName_%v", i), func(t *testing.T) { ua := uasurfer.Parse(userAgent.UserAgent) - if actual := getPlatformName(ua); actual != expected[i] { - t.Fatalf("%v Got %v, expected %v", userAgent.Name, actual, expected[i]) - } + actual := getPlatformName(ua) + assert.Equal(t, expected[i], actual) }) } } @@ -83,9 +83,8 @@ func TestGetOSName(t *testing.T) { t.Run(fmt.Sprintf("GetOSName_%v", i), func(t *testing.T) { ua := uasurfer.Parse(userAgent.UserAgent) - if actual := getOSName(ua); actual != expected[i] { - t.Fatalf("Got %v, expected %v", actual, expected[i]) - } + actual := getOSName(ua) + assert.Equal(t, expected[i], actual) }) } } @@ -113,9 +112,8 @@ func TestGetBrowserName(t *testing.T) { t.Run(fmt.Sprintf("GetBrowserName_%v", i), func(t *testing.T) { ua := uasurfer.Parse(userAgent.UserAgent) - if actual := getBrowserName(ua, userAgent.UserAgent); actual != expected[i] { - t.Fatalf("Got %v, expected %v", actual, expected[i]) - } + actual := getBrowserName(ua, userAgent.UserAgent) + assert.Equal(t, expected[i], actual) }) } } @@ -143,9 +141,8 @@ func TestGetBrowserVersion(t *testing.T) { t.Run(fmt.Sprintf("GetBrowserVersion_%v", i), func(t *testing.T) { ua := uasurfer.Parse(userAgent.UserAgent) - if actual := getBrowserVersion(ua, userAgent.UserAgent); actual != expected[i] { - t.Fatalf("Got %v, expected %v", actual, expected[i]) - } + actual := getBrowserVersion(ua, userAgent.UserAgent) + assert.Equal(t, expected[i], actual) }) } } diff --git a/app/web_hub.go b/app/web_hub.go index 8c5e828c1e..bdf7903023 100644 --- a/app/web_hub.go +++ b/app/web_hub.go @@ -72,7 +72,7 @@ func (a *App) TotalWebsocketConnections() int { func (a *App) HubStart() { // Total number of hubs is twice the number of CPUs. numberOfHubs := runtime.NumCPU() * 2 - mlog.Info(fmt.Sprintf("Starting %v websocket hubs", numberOfHubs)) + mlog.Info("Starting websocket hubs", mlog.Int("number_of_hubs", numberOfHubs)) a.Srv.Hubs = make([]*Hub, numberOfHubs) a.Srv.HubsStopCheckingForDeadlock = make(chan bool, 1) @@ -95,7 +95,12 @@ func (a *App) HubStart() { case <-ticker.C: for _, hub := range a.Srv.Hubs { if len(hub.broadcast) >= DEADLOCK_WARN { - mlog.Error(fmt.Sprintf("Hub processing might be deadlock on hub %v goroutine %v with %v events in the buffer", hub.connectionIndex, hub.goroutineId, len(hub.broadcast))) + mlog.Error( + "Hub processing might be deadlock with events in the buffer", + mlog.Int("hub", hub.connectionIndex), + mlog.Int("goroutine", hub.goroutineId), + mlog.Int("events", len(hub.broadcast)), + ) buf := make([]byte, 1<<16) runtime.Stack(buf, true) output := fmt.Sprintf("%s", buf) @@ -103,7 +108,7 @@ func (a *App) HubStart() { for _, part := range splits { if strings.Contains(part, fmt.Sprintf("%v", hub.goroutineId)) { - mlog.Error(fmt.Sprintf("Trace for possible deadlock goroutine %v", part)) + mlog.Error("Trace for possible deadlock goroutine", mlog.String("trace", part)) } } } @@ -433,7 +438,7 @@ func (h *Hub) Start() { doStart = func() { h.goroutineId = getGoroutineId() - mlog.Debug(fmt.Sprintf("Hub for index %v is starting with goroutine %v", h.connectionIndex, h.goroutineId)) + mlog.Debug("Hub for index is starting with goroutine", mlog.Int("index", h.connectionIndex), mlog.Int("goroutine", h.goroutineId)) connections := newHubConnectionIndex() @@ -489,7 +494,7 @@ func (h *Hub) Start() { select { case webCon.Send <- msg: default: - mlog.Error(fmt.Sprintf("webhub.broadcast: cannot send, closing websocket for userId=%v", webCon.UserId)) + mlog.Error("webhub.broadcast: cannot send, closing websocket for user", mlog.String("user_id", webCon.UserId)) close(webCon.Send) connections.Remove(webCon) } @@ -523,7 +528,7 @@ func (h *Hub) Start() { doRecover = func() { if !h.ExplicitStop { if r := recover(); r != nil { - mlog.Error(fmt.Sprintf("Recovering from Hub panic. Panic was: %v", r)) + mlog.Error("Recovering from Hub panic.", mlog.Any("panic", r)) } else { mlog.Error("Webhub stopped unexpectedly. Recovering.") } diff --git a/app/web_hub_test.go b/app/web_hub_test.go index dc141695b6..27b922a3a3 100644 --- a/app/web_hub_test.go +++ b/app/web_hub_test.go @@ -100,6 +100,6 @@ func TestHubStopRaceCondition(t *testing.T) { select { case <-done: case <-time.After(15 * time.Second): - t.Fatalf("hub call did not return within 15 seconds after stop") + require.FailNow(t, "hub call did not return within 15 seconds after stop") } } diff --git a/build/Jenkinsfile.branch b/build/Jenkinsfile.branch index 8e84ceaecb..79c61da673 100644 --- a/build/Jenkinsfile.branch +++ b/build/Jenkinsfile.branch @@ -9,7 +9,7 @@ def platformStages = new org.mattermost.PlatformStages() def rndEE = UUID.randomUUID().toString() def rndTE = UUID.randomUUID().toString() -def mmBuilderServer = 'mattermost/mattermost-build-server:feb-28-2019' +def mmBuilderServer = 'mattermost/mattermost-build-server:sep-17-2019' def mmBuilderWebapp = 'mattermost/mattermost-build-webapp:oct-2-2018' pipeline { diff --git a/build/Jenkinsfile.pr b/build/Jenkinsfile.pr index c380471cd4..41b41d6a36 100644 --- a/build/Jenkinsfile.pr +++ b/build/Jenkinsfile.pr @@ -77,7 +77,7 @@ pipeline { } steps { - withDockerContainer(args: '-u root --privileged -v ${WORKSPACE}/src:/go/src/', image: 'mattermost/mattermost-build-server:feb-28-2019') { + withDockerContainer(args: '-u root --privileged -v ${WORKSPACE}/src:/go/src/', image: 'mattermost/mattermost-build-server:sep-17-2019') { ansiColor('xterm') { sh """ cd /go/src/github.com/mattermost/mattermost-server @@ -96,7 +96,7 @@ pipeline { } steps { - withDockerContainer(args: '-u root --privileged -v ${WORKSPACE}/src:/go/src/', image: 'mattermost/mattermost-build-server:feb-28-2019') { + withDockerContainer(args: '-u root --privileged -v ${WORKSPACE}/src:/go/src/', image: 'mattermost/mattermost-build-server:sep-17-2019') { ansiColor('xterm') { sh """ cd /go/src/github.com/mattermost/mattermost-server @@ -272,7 +272,7 @@ pipeline { } } - withDockerContainer(args: "-u root --privileged --net ${COMPOSE_PROJECT_NAME}_mm-test -v ${WORKSPACE}/src:/go/src/", image: 'mattermost/mattermost-build-server:feb-28-2019') { + withDockerContainer(args: "-u root --privileged --net ${COMPOSE_PROJECT_NAME}_mm-test -v ${WORKSPACE}/src:/go/src/", image: 'mattermost/mattermost-build-server:sep-17-2019') { ansiColor('xterm') { sh """ cd /go/src/github.com/mattermost/mattermost-server @@ -326,7 +326,7 @@ pipeline { } } - withDockerContainer(args: "-u root --privileged --net ${COMPOSE_PROJECT_NAME}_mm-test -v ${WORKSPACE}/src:/go/src/", image: 'mattermost/mattermost-build-server:feb-28-2019') { + withDockerContainer(args: "-u root --privileged --net ${COMPOSE_PROJECT_NAME}_mm-test -v ${WORKSPACE}/src:/go/src/", image: 'mattermost/mattermost-build-server:sep-17-2019') { ansiColor('xterm') { sh """ cd /go/src/github.com/mattermost/mattermost-server @@ -369,7 +369,7 @@ pipeline { } } - withDockerContainer(args: "-u root --privileged --net ${COMPOSE_PROJECT_NAME}_mm-test -v ${WORKSPACE}/src:/go/src/", image: 'mattermost/mattermost-build-server:feb-28-2019') { + withDockerContainer(args: "-u root --privileged --net ${COMPOSE_PROJECT_NAME}_mm-test -v ${WORKSPACE}/src:/go/src/", image: 'mattermost/mattermost-build-server:sep-17-2019') { ansiColor('xterm') { sh """ cd /go/src/github.com/mattermost/mattermost-server diff --git a/build/README.md b/build/README.md index 8ce9f62028..635cd63907 100644 --- a/build/README.md +++ b/build/README.md @@ -14,6 +14,6 @@ We have a docker image to build `mattermost-server` and it is based on Go docker In our Docker Hub Repository we have the following images: -- `mattermost/mattermost-build-server:dec-7-2018` which is based on Go 1.11 you can use for MM versions <= `5.9.0` -- `mattermost/mattermost-build-server:feb-28-2019` which is based on Go 1.12 - +- `mattermost/mattermost-build-server:dec-7-2018` which is based on Go 1.11 you can use for MM versions <= `5.8.0` +- `mattermost/mattermost-build-server:feb-28-2019` which is based on Go 1.12 you can use for MM versions >= `5.9.0` <= `5.15.0` +- `mattermost/mattermost-build-server:sep-17-2019` which is based on Go 1.12.9 you can use for MM versions >= `5.16.0` diff --git a/build/local-test-env.sh b/build/local-test-env.sh index e895bf8788..c2c6c25945 100755 --- a/build/local-test-env.sh +++ b/build/local-test-env.sh @@ -43,7 +43,7 @@ up() -e MM_EMAILSETTINGS_SMTPSERVER="inbucket" \ -e MM_EMAILSETTINGS_SMTPPORT="10025" \ -e MM_ELASTICSEARCHSETTINGS_CONNECTIONURL="http://elasticsearch:9200" \ - mattermost/mattermost-build-server:dec-7-2018 /bin/bash + mattermost/mattermost-build-server:sep-17-2019 /bin/bash } down() diff --git a/config/default.go b/config/default.go index 4cdb5d6d14..824ccb0d14 100644 --- a/config/default.go +++ b/config/default.go @@ -1,4 +1,4 @@ -//go:generate go run config_generator/main.go +//go:generate go run -mod=vendor config_generator/main.go // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See License.txt for license information. diff --git a/config/file.go b/config/file.go index 718403c6c9..40ef6a0791 100644 --- a/config/file.go +++ b/config/file.go @@ -92,6 +92,16 @@ func resolveConfigFilePath(path string) (string, error) { return "", fmt.Errorf("failed to find config file %s", path) } +// resolveFilePath uses the name if name is absolute path. +// otherwise returns the combined path/name +func (fs *FileStore) resolveFilePath(name string) string { + // Absolute paths are explicit and require no resolution. + if filepath.IsAbs(name) { + return name + } + return filepath.Join(filepath.Dir(fs.path), name) +} + // Set replaces the current configuration in its entirety and updates the backing store. func (fs *FileStore) Set(newCfg *model.Config) (*model.Config, error) { return fs.commonStore.set(newCfg, true, func(cfg *model.Config) error { @@ -160,7 +170,7 @@ func (fs *FileStore) Load() (err error) { // GetFile fetches the contents of a previously persisted configuration file. func (fs *FileStore) GetFile(name string) ([]byte, error) { - resolvedPath := filepath.Join(filepath.Dir(fs.path), name) + resolvedPath := fs.resolveFilePath(name) data, err := ioutil.ReadFile(resolvedPath) if err != nil { @@ -172,7 +182,7 @@ func (fs *FileStore) GetFile(name string) ([]byte, error) { // SetFile sets or replaces the contents of a configuration file. func (fs *FileStore) SetFile(name string, data []byte) error { - resolvedPath := filepath.Join(filepath.Dir(fs.path), name) + resolvedPath := fs.resolveFilePath(name) err := ioutil.WriteFile(resolvedPath, data, 0777) if err != nil { @@ -188,7 +198,7 @@ func (fs *FileStore) HasFile(name string) (bool, error) { return false, nil } - resolvedPath := filepath.Join(filepath.Dir(fs.path), name) + resolvedPath := fs.resolveFilePath(name) _, err := os.Stat(resolvedPath) if err != nil && os.IsNotExist(err) { @@ -202,6 +212,11 @@ func (fs *FileStore) HasFile(name string) (bool, error) { // RemoveFile removes a previously persisted configuration file. func (fs *FileStore) RemoveFile(name string) error { + if filepath.IsAbs(name) { + // Don't delete absolute filenames, as may be mounted drive, etc. + mlog.Debug("Skipping removal of configuration file with absolute path", mlog.String("filename", name)) + return nil + } resolvedPath := filepath.Join(filepath.Dir(fs.path), name) err := os.Remove(resolvedPath) diff --git a/config/file_test.go b/config/file_test.go index 2c18d4bf80..e47df06034 100644 --- a/config/file_test.go +++ b/config/file_test.go @@ -890,6 +890,17 @@ func TestFileGetFile(t *testing.T) { require.NoError(t, err) require.Equal(t, []byte("test"), data) }) + + t.Run("get via absolute path", func(t *testing.T) { + err := fs.SetFile("new", []byte("new file")) + require.NoError(t, err) + + data, err := fs.GetFile(filepath.Join(filepath.Dir(path), "new")) + + require.NoError(t, err) + require.Equal(t, []byte("new file"), data) + }) + } func TestFileSetFile(t *testing.T) { @@ -920,6 +931,18 @@ func TestFileSetFile(t *testing.T) { require.NoError(t, err) require.Equal(t, []byte("overwritten file"), data) }) + + t.Run("set via absolute path", func(t *testing.T) { + absolutePath := filepath.Join(filepath.Dir(path), "new") + err := fs.SetFile(absolutePath, []byte("new file")) + require.NoError(t, err) + + data, err := fs.GetFile("new") + + require.NoError(t, err) + require.Equal(t, []byte("new file"), data) + }) + } func TestFileHasFile(t *testing.T) { @@ -987,6 +1010,23 @@ func TestFileHasFile(t *testing.T) { require.NoError(t, err) require.False(t, has) }) + + t.Run("has via absolute path", func(t *testing.T) { + path, tearDown := setupConfigFile(t, minimalConfig) + defer tearDown() + + fs, err := config.NewFileStore(path, true) + require.NoError(t, err) + defer fs.Close() + + err = fs.SetFile("existing", []byte("existing file")) + require.NoError(t, err) + + has, err := fs.HasFile(filepath.Join(filepath.Dir(path), "existing")) + require.NoError(t, err) + require.True(t, has) + }) + } func TestFileRemoveFile(t *testing.T) { @@ -1052,6 +1092,27 @@ func TestFileRemoveFile(t *testing.T) { _, err = fs.GetFile("existing") require.Error(t, err) }) + + t.Run("don't remove via absolute path", func(t *testing.T) { + path, tearDown := setupConfigFile(t, minimalConfig) + defer tearDown() + + fs, err := config.NewFileStore(path, true) + require.NoError(t, err) + defer fs.Close() + + err = fs.SetFile("existing", []byte("existing file")) + require.NoError(t, err) + + filename := filepath.Join(filepath.Dir(path), "existing") + err = fs.RemoveFile(filename) + require.NoError(t, err) + + has, err := fs.HasFile(filename) + require.NoError(t, err) + require.True(t, has) + + }) } func TestFileStoreString(t *testing.T) { diff --git a/go.mod b/go.mod index ff2d36a861..1d28dc09cb 100644 --- a/go.mod +++ b/go.mod @@ -16,7 +16,6 @@ require ( github.com/fortytw2/leaktest v1.3.0 // indirect github.com/fsnotify/fsnotify v1.4.7 github.com/go-gorp/gorp v2.0.0+incompatible // indirect - github.com/go-ldap/ldap v3.0.3+incompatible // indirect github.com/go-redis/redis v6.15.2+incompatible github.com/go-sql-driver/mysql v1.4.1 github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0 diff --git a/go.sum b/go.sum index b9f77b9f1e..8d60f129f5 100644 --- a/go.sum +++ b/go.sum @@ -3,8 +3,6 @@ cloud.google.com/go v0.31.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMT cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= cloud.google.com/go v0.37.1/go.mod h1:SAbnLi6YTSPKSI0dTUEOVLCkyPfKXK8n4ibqiMoj4ok= contrib.go.opencensus.io/exporter/ocagent v0.4.9/go.mod h1:ueLzZcP7LPhPulEBukGn4aLh7Mx9YJwpVJ9nL2FYltw= -git.apache.org/thrift.git v0.12.0/go.mod h1:fPE2ZNJGynbRyZ4dJvy6G277gSllfV2HJqblrnkyeyg= -github.com/apache/thrift v0.0.0-20180902110319-2566ecd5d999/go.mod h1:cp2SuWMxlEZw2r+iP2GNCdIi4C1qmUzdZFSVb+bacwQ= github.com/Azure/azure-sdk-for-go v26.5.0+incompatible/go.mod h1:9XXNKU+eRnpl9moKnB4QOLf1HestfXbmab5FXxiDBjc= github.com/Azure/go-autorest v11.5.2+incompatible/go.mod h1:r+4oMnoxhatjLLJ6zxSWATqVooLgysK6ZNox3g/xq24= github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ= @@ -25,6 +23,7 @@ github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuy github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= github.com/anmitsu/go-shlex v0.0.0-20161002113705-648efa622239/go.mod h1:2FmKhYUyUczH0OGQWaF5ceTx0UBShxjsH6f8oGKYe2c= github.com/apache/thrift v0.0.0-20180902110319-2566ecd5d999/go.mod h1:cp2SuWMxlEZw2r+iP2GNCdIi4C1qmUzdZFSVb+bacwQ= +github.com/apache/thrift v0.0.0-20180902110319-2566ecd5d999/go.mod h1:cp2SuWMxlEZw2r+iP2GNCdIi4C1qmUzdZFSVb+bacwQ= github.com/apache/thrift v0.12.0/go.mod h1:cp2SuWMxlEZw2r+iP2GNCdIi4C1qmUzdZFSVb+bacwQ= github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8= github.com/armon/go-metrics v0.0.0-20180917152333-f0300d1749da h1:8GUt8eRujhVEGZFFEjBj46YV4rDjvGrNxb0KMWYkL2I= @@ -88,8 +87,6 @@ github.com/gliderlabs/ssh v0.1.1/go.mod h1:U7qILu1NlMHj9FlMhZLlkCdDnU1DBEAqr0aev github.com/go-gorp/gorp v2.0.0+incompatible h1:dIQPsBtl6/H1MjVseWuWPXa7ET4p6Dve4j3Hg+UjqYw= github.com/go-gorp/gorp v2.0.0+incompatible/go.mod h1:7IfkAQnO7jfT/9IQ3R9wL1dFhukN6aQxzKTHnkxzA/E= github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= -github.com/go-ldap/ldap v3.0.3+incompatible h1:HTeSZO8hWMS1Rgb2Ziku6b8a7qRIZZMHjsvuZyatzwk= -github.com/go-ldap/ldap v3.0.3+incompatible/go.mod h1:qfd9rJvER9Q0/D/Sqn1DfHRoBp40uXYvFoEVrNEPqRc= github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE= github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk= github.com/go-redis/redis v6.15.2+incompatible h1:9SpNVG76gr6InJGxoZ6IuuxaCOQwDAhzyXg+Bs+0Sb4= diff --git a/i18n/en.json b/i18n/en.json index bdb1744c5f..44e3abd5e4 100644 --- a/i18n/en.json +++ b/i18n/en.json @@ -4192,7 +4192,7 @@ }, { "id": "mfa.validate_token.authenticate.app_error", - "translation": "Error trying to authenticate MFA token" + "translation": "Invalid MFA token." }, { "id": "migrations.worker.run_advanced_permissions_phase_2_migration.invalid_progress", diff --git a/model/version.go b/model/version.go index 8f783a17ae..a165be095b 100644 --- a/model/version.go +++ b/model/version.go @@ -13,6 +13,8 @@ import ( // It should be maintained in chronological order with most current // release at the front of the list. var versions = []string{ + "5.18.0", + "5.17.0", "5.16.0", "5.15.0", "5.14.0", diff --git a/plugin/client.go b/plugin/client.go index d74663d1ec..e445f9e1e0 100644 --- a/plugin/client.go +++ b/plugin/client.go @@ -10,7 +10,6 @@ import ( const ( INTERNAL_KEY_PREFIX = "mmi_" BOT_USER_KEY = INTERNAL_KEY_PREFIX + "botid" - CHANNEL_KEY = INTERNAL_KEY_PREFIX + "channelid" ) // Starts the serving of a Mattermost plugin over net/rpc. gRPC is not yet supported. diff --git a/plugin/helpers_channels.go b/plugin/helpers_channels.go deleted file mode 100644 index 710b022303..0000000000 --- a/plugin/helpers_channels.go +++ /dev/null @@ -1,111 +0,0 @@ -// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. -// See LICENSE.txt for license information. - -package plugin - -import ( - "github.com/mattermost/mattermost-server/model" - "github.com/mattermost/mattermost-server/utils" - "github.com/pkg/errors" -) - -func (p *HelpersImpl) EnsureChannel(channel *model.Channel) (retChannelId string, retErr error) { - // Must provide a channel with a name and teadId - if channel == nil || len(channel.Name) < 1 || len(channel.TeamId) < 1 { - return "", errors.New("passed a bad channel, nil or no name or no team id") - } - - // If we fail for any reason, this could be a race between creation of channel and - // retrieval from another EnsureChannel. Just try the basic retrieve existing again. - defer func() { - if retChannelId == "" || retErr != nil { - var err error - var channelIdBytes []byte - - err = utils.ProgressiveRetry(func() error { - channelIdBytes, err = p.API.KVGet(CHANNEL_KEY) - if err != nil { - return err - } - return nil - }) - - if err == nil && channelIdBytes != nil { - retChannelId = string(channelIdBytes) - retErr = nil - } - } - }() - - // Fetch channel ID from key value store - channelIdBytes, kvGetErr := p.API.KVGet(CHANNEL_KEY) - if kvGetErr != nil { - // Failed to retrive the value of channel - return "", errors.Wrap(kvGetErr, "failed to get channel ID") - } - - var existingChannel *model.Channel - var channelGetErr *model.AppError - - // If channel ID exists, get existing channel by ID else get it by Name - if channelIdBytes != nil { - existingChannel, channelGetErr = p.API.GetChannel(string(channelIdBytes)) - if channelGetErr != nil { - return "", errors.Wrap(channelGetErr, "failed to get channel by ID") - } - } else { - existingChannel, channelGetErr = p.API.GetChannelByName(channel.TeamId, channel.Name, false) - if channelGetErr != nil { - return "", errors.Wrap(channelGetErr, "failed to get channel by name") - } - } - - // If channel exists, update the metadata - if existingChannel != nil { - return updateChannel(p, existingChannel, channel) - } - - // Create a new channel - createdChannel, createChannelErr := p.API.CreateChannel(channel) - if createChannelErr != nil { - return "", errors.Wrap(createChannelErr, "failed to create channel") - } - - // Set the new channel id in key value store - if kvSetErr := p.API.KVSet(CHANNEL_KEY, []byte(createdChannel.Id)); kvSetErr != nil { - p.API.LogWarn("Failed to set created channel id.", "channelid", createdChannel.Id, "err", kvSetErr) - } - - return createdChannel.Id, nil -} - -func updateChannel(p *HelpersImpl, existing *model.Channel, new *model.Channel) (string, error) { - // Update metadata of the channel - if updateErr := updateChannelMeta(existing, new); updateErr != nil { - return "", errors.Wrap(updateErr, "Failed to update the metadata of existing channel") - } - - // Send the updates to API - updatedChannel, channelUpdateErr := p.API.UpdateChannel(existing) - if channelUpdateErr != nil { - return "", errors.Wrap(channelUpdateErr, "Failed to update the existing channel") - } - - // Channel exists! - return updatedChannel.Id, nil -} - -func updateChannelMeta(existing *model.Channel, new *model.Channel) error { - // Check if channels are of different types - if existing.Type != new.Type { - return errors.New("Channel type cannot be updated") - } - - // Update metadata of channel - existing.Name = new.Name - existing.DisplayName = new.DisplayName - existing.Purpose = new.Purpose - existing.Header = new.Header - - return nil -} diff --git a/plugin/helpers_channels_test.go b/plugin/helpers_channels_test.go deleted file mode 100644 index 691466ed08..0000000000 --- a/plugin/helpers_channels_test.go +++ /dev/null @@ -1,297 +0,0 @@ -// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. -// See LICENSE.txt for license information. - -package plugin_test - -import ( - "testing" - - "github.com/mattermost/mattermost-server/model" - "github.com/mattermost/mattermost-server/plugin" - "github.com/mattermost/mattermost-server/plugin/plugintest" - "github.com/stretchr/testify/assert" -) - -func TestEnsureChannel(t *testing.T) { - setupAPI := func() *plugintest.API { - return &plugintest.API{} - } - - testChannel := &model.Channel{ - Id: model.NewId(), - TeamId: model.NewId(), - Type: "public", - Name: "test_channel", - DisplayName: "Test Channel", - Purpose: "Testing EnsureChannel", - Header: "Testing EnsureChannel", - } - - t.Run("bad parameters", func(t *testing.T) { - t.Run("no channel", func(t *testing.T) { - p := &plugin.HelpersImpl{} - channelId, err := p.EnsureChannel(nil) - assert.Equal(t, "", channelId) - assert.NotNil(t, err) - }) - t.Run("empty name", func(t *testing.T) { - p := &plugin.HelpersImpl{} - channelId, err := p.EnsureChannel(&model.Channel{ - Name: "", - }) - assert.Equal(t, "", channelId) - assert.NotNil(t, err) - }) - t.Run("name without teamId", func(t *testing.T) { - p := &plugin.HelpersImpl{} - channelId, err := p.EnsureChannel(&model.Channel{ - Name: "test_channel", - }) - assert.Equal(t, "", channelId) - assert.NotNil(t, err) - }) - t.Run("teamId without name", func(t *testing.T) { - p := &plugin.HelpersImpl{} - channelId, err := p.EnsureChannel(&model.Channel{ - TeamId: model.NewId(), - }) - assert.Equal(t, "", channelId) - assert.NotNil(t, err) - }) - t.Run("teamId with empty name", func(t *testing.T) { - p := &plugin.HelpersImpl{} - channelId, err := p.EnsureChannel(&model.Channel{ - TeamId: model.NewId(), - }) - assert.Equal(t, "", channelId) - assert.NotNil(t, err) - }) - }) - - t.Run("if channel already exists in Key Value store", func(t *testing.T) { - t.Run("should return an error if unable to get channel id", func(t *testing.T) { - api := setupAPI() - api.On("KVGet", plugin.CHANNEL_KEY).Return(nil, &model.AppError{}) - defer api.AssertExpectations(t) - - p := &plugin.HelpersImpl{API: api} - - channelId, err := p.EnsureChannel(testChannel) - - assert.Equal(t, "", channelId) - assert.NotNil(t, err) - }) - t.Run("should return an error if unable to get channel", func(t *testing.T) { - expectedChannelId := model.NewId() - - api := setupAPI() - api.On("KVGet", plugin.CHANNEL_KEY).Return([]byte(expectedChannelId), nil) - api.On("GetChannel", expectedChannelId).Return(nil, &model.AppError{}) - - p := &plugin.HelpersImpl{API: api} - - channelId, err := p.EnsureChannel(testChannel) - - assert.Equal(t, "", channelId) - assert.NotNil(t, err) - }) - t.Run("should return an error if unable to update channel", func(t *testing.T) { - expectedChannelId := model.NewId() - - api := setupAPI() - api.On("KVGet", plugin.CHANNEL_KEY).Return([]byte(expectedChannelId), nil) - api.On("GetChannel", expectedChannelId).Return(testChannel, nil) - api.On("UpdateChannel", testChannel).Return(nil, &model.AppError{}) - defer api.AssertExpectations(t) - - p := &plugin.HelpersImpl{API: api} - - channelId, err := p.EnsureChannel(testChannel) - - assert.Equal(t, "", channelId) - assert.NotNil(t, err) - }) - t.Run("should return the Id of existing channel if metadata is same", func(t *testing.T) { - api := setupAPI() - api.On("KVGet", plugin.CHANNEL_KEY).Return([]byte(testChannel.Id), nil) - api.On("GetChannel", testChannel.Id).Return(testChannel, nil) - api.On("UpdateChannel", testChannel).Return(testChannel, nil) - defer api.AssertExpectations(t) - - p := &plugin.HelpersImpl{API: api} - - channelId, err := p.EnsureChannel(testChannel) - - assert.Equal(t, testChannel.Id, channelId) - assert.Nil(t, err) - }) - t.Run("should return error if channel type is different from existing one", func(t *testing.T) { - privChannel := &model.Channel{ - Id: model.NewId(), - Type: "private", - TeamId: testChannel.TeamId, - Name: testChannel.Name, - } - api := setupAPI() - api.On("KVGet", plugin.CHANNEL_KEY).Return([]byte(testChannel.Id), nil) - api.On("GetChannel", testChannel.Id).Return(privChannel, nil) - defer api.AssertExpectations(t) - - p := &plugin.HelpersImpl{API: api} - - channelId, err := p.EnsureChannel(testChannel) - - assert.Equal(t, "", channelId) - assert.NotNil(t, err) - }) - t.Run("should return the Id of updated channel if metadata is different", func(t *testing.T) { - updatedChannel := &model.Channel{ - Id: model.NewId(), - TeamId: testChannel.TeamId, - Name: testChannel.Name, - } - api := setupAPI() - api.On("KVGet", plugin.CHANNEL_KEY).Return([]byte(testChannel.Id), nil) - api.On("GetChannel", testChannel.Id).Return(testChannel, nil) - api.On("UpdateChannel", testChannel).Return(updatedChannel, nil) - defer api.AssertExpectations(t) - - p := &plugin.HelpersImpl{API: api} - - channelId, err := p.EnsureChannel(testChannel) - - assert.Equal(t, updatedChannel.Id, channelId) - assert.Nil(t, err) - }) - }) - - t.Run("if channel is not in Key Value store but already exists", func(t *testing.T) { - t.Run("should return an error if unable to get channel", func(t *testing.T) { - api := setupAPI() - api.On("KVGet", plugin.CHANNEL_KEY).Return(nil, nil) - api.On("GetChannelByName", testChannel.TeamId, testChannel.Name, false).Return(nil, &model.AppError{}) - defer api.AssertExpectations(t) - - p := &plugin.HelpersImpl{API: api} - - channelId, err := p.EnsureChannel(testChannel) - - assert.Equal(t, "", channelId) - assert.NotNil(t, err) - }) - t.Run("should return the Id of existing channel if metadata is same", func(t *testing.T) { - api := setupAPI() - api.On("KVGet", plugin.CHANNEL_KEY).Return(nil, nil) - api.On("GetChannelByName", testChannel.TeamId, testChannel.Name, false).Return(testChannel, nil) - api.On("UpdateChannel", testChannel).Return(testChannel, nil) - defer api.AssertExpectations(t) - - p := &plugin.HelpersImpl{API: api} - - channelId, err := p.EnsureChannel(testChannel) - - assert.Equal(t, testChannel.Id, channelId) - assert.Nil(t, err) - }) - t.Run("should return error if failed to update the channel", func(t *testing.T) { - api := setupAPI() - api.On("KVGet", plugin.CHANNEL_KEY).Return(nil, nil) - api.On("GetChannelByName", testChannel.TeamId, testChannel.Name, false).Return(testChannel, nil) - api.On("UpdateChannel", testChannel).Return(nil, &model.AppError{}) - defer api.AssertExpectations(t) - - p := &plugin.HelpersImpl{API: api} - - channelId, err := p.EnsureChannel(testChannel) - - assert.Equal(t, "", channelId) - assert.NotNil(t, err) - }) - t.Run("should return the Id of updated channel if metadata is different", func(t *testing.T) { - updatedChannel := &model.Channel{ - Id: model.NewId(), - TeamId: testChannel.TeamId, - Name: testChannel.Name, - } - api := setupAPI() - api.On("KVGet", plugin.CHANNEL_KEY).Return(nil, nil) - api.On("GetChannelByName", testChannel.TeamId, testChannel.Name, false).Return(testChannel, nil) - api.On("UpdateChannel", testChannel).Return(updatedChannel, nil) - defer api.AssertExpectations(t) - - p := &plugin.HelpersImpl{API: api} - - channelId, err := p.EnsureChannel(testChannel) - - assert.Equal(t, updatedChannel.Id, channelId) - assert.Nil(t, err) - }) - t.Run("should return error if channel type is different from existing one", func(t *testing.T) { - privChannel := &model.Channel{ - Id: model.NewId(), - Type: "private", - TeamId: testChannel.TeamId, - Name: testChannel.Name, - } - api := setupAPI() - api.On("KVGet", plugin.CHANNEL_KEY).Return(nil, nil) - api.On("GetChannelByName", testChannel.TeamId, testChannel.Name, false).Return(privChannel, nil) - defer api.AssertExpectations(t) - - p := &plugin.HelpersImpl{API: api} - - channelId, err := p.EnsureChannel(testChannel) - - assert.Equal(t, "", channelId) - assert.NotNil(t, err) - }) - }) - - t.Run("if channel does not exist", func(t *testing.T) { - t.Run("should create new channel and return the Id", func(t *testing.T) { - api := setupAPI() - api.On("KVGet", plugin.CHANNEL_KEY).Return(nil, nil) - api.On("GetChannelByName", testChannel.TeamId, testChannel.Name, false).Return(nil, nil) - api.On("CreateChannel", testChannel).Return(testChannel, nil) - api.On("KVSet", plugin.CHANNEL_KEY, []byte(testChannel.Id)).Return(nil) - defer api.AssertExpectations(t) - - p := &plugin.HelpersImpl{API: api} - - channelId, err := p.EnsureChannel(testChannel) - - assert.Equal(t, testChannel.Id, channelId) - assert.Nil(t, err) - }) - t.Run("should return error if unable to create new channel", func(t *testing.T) { - api := setupAPI() - api.On("KVGet", plugin.CHANNEL_KEY).Return(nil, nil) - api.On("GetChannelByName", testChannel.TeamId, testChannel.Name, false).Return(nil, nil) - api.On("CreateChannel", testChannel).Return(nil, &model.AppError{}) - defer api.AssertExpectations(t) - - p := &plugin.HelpersImpl{API: api} - - channelId, err := p.EnsureChannel(testChannel) - - assert.Equal(t, "", channelId) - assert.NotNil(t, err) - }) - t.Run("should log and return id if unable to write to Key Value store", func(t *testing.T) { - api := setupAPI() - api.On("KVGet", plugin.CHANNEL_KEY).Return(nil, nil) - api.On("GetChannelByName", testChannel.TeamId, testChannel.Name, false).Return(nil, nil) - api.On("CreateChannel", testChannel).Return(testChannel, nil) - api.On("KVSet", plugin.CHANNEL_KEY, []byte(testChannel.Id)).Return(&model.AppError{}) - api.On("LogWarn", "Failed to set created channel id.", "channelid", testChannel.Id, "err", &model.AppError{}) - defer api.AssertExpectations(t) - - p := &plugin.HelpersImpl{API: api} - - channelId, err := p.EnsureChannel(testChannel) - - assert.Equal(t, testChannel.Id, channelId) - assert.Nil(t, err) - }) - }) -} diff --git a/scripts/license-check.sh b/scripts/license-check.sh index 7c0e06303c..bffd03b49f 100755 --- a/scripts/license-check.sh +++ b/scripts/license-check.sh @@ -3,7 +3,7 @@ set -e IFS=$'\n' count=0 for fileType in GoFiles; do - for file in `go list -f $'{{range .GoFiles}}{{$.Dir}}/{{.}}\n{{end}}' "$@"`; do + for file in `go list -mod=vendor -f $'{{range .GoFiles}}{{$.Dir}}/{{.}}\n{{end}}' "$@"`; do case $file in */utils/lru.go|*/utils/imgutils/gif.go|*/store/storetest/mocks/*|*/services/*/mocks/*|*/app/plugin/jira/plugin_*|*/plugin/plugintest/*|*/app/plugin/zoom/plugin_*|*/einterfaces/mocks/*) # Third-party, doesn't require a header. diff --git a/store/layer_generators/main.go b/store/layer_generators/main.go index 09d0ba3be7..8ffee95b4e 100644 --- a/store/layer_generators/main.go +++ b/store/layer_generators/main.go @@ -246,14 +246,13 @@ func (s *{{$.Name}}{{$substoreName}}Store) {{$index}}({{$element.Params | joinPa {{ else }} {{$element.Results | genResultsVars}} := s.{{$substoreName}}Store.{{$index}}({{$element.Params | joinParams}}) {{ end }} - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if {{$element.Results | errorToBoolean}} { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("{{$substoreName}}Store.{{$index}}", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("{{$substoreName}}Store.{{$index}}", success, elapsed) } return {{$element.Results | genResultsVars}} } diff --git a/store/sqlstore/channel_store.go b/store/sqlstore/channel_store.go index 376ac1eb34..42e9647b9e 100644 --- a/store/sqlstore/channel_store.go +++ b/store/sqlstore/channel_store.go @@ -1419,7 +1419,7 @@ func (s SqlChannelStore) IsUserInChannelUseCache(userId string, channelId string ids, err := s.GetAllChannelMembersForUser(userId, true, false) if err != nil { - mlog.Error("SqlChannelStore.IsUserInChannelUseCache: " + err.Error()) + mlog.Error("Error getting all channel members for user", mlog.Err(err)) return false } @@ -2008,7 +2008,7 @@ func (s SqlChannelStore) GetChannelsByIds(channelIds []string) ([]*model.Channel _, err := s.GetReplica().Select(&channels, query, params) if err != nil { - mlog.Error(fmt.Sprint(err)) + mlog.Error("Query error getting channels by ids", mlog.Err(err)) return nil, model.NewAppError("SqlChannelStore.GetChannelsByIds", "store.sql_channel.get_channels_by_ids.app_error", nil, "", http.StatusInternalServerError) } return channels, nil diff --git a/store/timer_layer.go b/store/timer_layer.go index 5bdbc5c00b..3632de3d81 100644 --- a/store/timer_layer.go +++ b/store/timer_layer.go @@ -333,14 +333,13 @@ func (s *TimerLayerAuditStore) Get(user_id string, offset int, limit int) (model resultVar0, resultVar1 := s.AuditStore.Get(user_id, offset, limit) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("AuditStore.Get", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("AuditStore.Get", success, elapsed) } return resultVar0, resultVar1 } @@ -350,14 +349,13 @@ func (s *TimerLayerAuditStore) PermanentDeleteBatch(endTime int64, limit int64) resultVar0, resultVar1 := s.AuditStore.PermanentDeleteBatch(endTime, limit) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("AuditStore.PermanentDeleteBatch", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("AuditStore.PermanentDeleteBatch", success, elapsed) } return resultVar0, resultVar1 } @@ -367,14 +365,13 @@ func (s *TimerLayerAuditStore) PermanentDeleteByUser(userId string) *model.AppEr resultVar0 := s.AuditStore.PermanentDeleteByUser(userId) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar0 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("AuditStore.PermanentDeleteByUser", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("AuditStore.PermanentDeleteByUser", success, elapsed) } return resultVar0 } @@ -384,14 +381,13 @@ func (s *TimerLayerAuditStore) Save(audit *model.Audit) *model.AppError { resultVar0 := s.AuditStore.Save(audit) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar0 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("AuditStore.Save", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("AuditStore.Save", success, elapsed) } return resultVar0 } @@ -401,14 +397,13 @@ func (s *TimerLayerBotStore) Get(userId string, includeDeleted bool) (*model.Bot resultVar0, resultVar1 := s.BotStore.Get(userId, includeDeleted) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("BotStore.Get", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("BotStore.Get", success, elapsed) } return resultVar0, resultVar1 } @@ -418,14 +413,13 @@ func (s *TimerLayerBotStore) GetAll(options *model.BotGetOptions) ([]*model.Bot, resultVar0, resultVar1 := s.BotStore.GetAll(options) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("BotStore.GetAll", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("BotStore.GetAll", success, elapsed) } return resultVar0, resultVar1 } @@ -435,14 +429,13 @@ func (s *TimerLayerBotStore) PermanentDelete(userId string) *model.AppError { resultVar0 := s.BotStore.PermanentDelete(userId) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar0 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("BotStore.PermanentDelete", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("BotStore.PermanentDelete", success, elapsed) } return resultVar0 } @@ -452,14 +445,13 @@ func (s *TimerLayerBotStore) Save(bot *model.Bot) (*model.Bot, *model.AppError) resultVar0, resultVar1 := s.BotStore.Save(bot) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("BotStore.Save", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("BotStore.Save", success, elapsed) } return resultVar0, resultVar1 } @@ -469,14 +461,13 @@ func (s *TimerLayerBotStore) Update(bot *model.Bot) (*model.Bot, *model.AppError resultVar0, resultVar1 := s.BotStore.Update(bot) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("BotStore.Update", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("BotStore.Update", success, elapsed) } return resultVar0, resultVar1 } @@ -486,14 +477,13 @@ func (s *TimerLayerChannelStore) AnalyticsDeletedTypeCount(teamId string, channe resultVar0, resultVar1 := s.ChannelStore.AnalyticsDeletedTypeCount(teamId, channelType) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.AnalyticsDeletedTypeCount", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.AnalyticsDeletedTypeCount", success, elapsed) } return resultVar0, resultVar1 } @@ -503,14 +493,13 @@ func (s *TimerLayerChannelStore) AnalyticsTypeCount(teamId string, channelType s resultVar0, resultVar1 := s.ChannelStore.AnalyticsTypeCount(teamId, channelType) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.AnalyticsTypeCount", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.AnalyticsTypeCount", success, elapsed) } return resultVar0, resultVar1 } @@ -520,14 +509,13 @@ func (s *TimerLayerChannelStore) AutocompleteInTeam(teamId string, term string, resultVar0, resultVar1 := s.ChannelStore.AutocompleteInTeam(teamId, term, includeDeleted) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.AutocompleteInTeam", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.AutocompleteInTeam", success, elapsed) } return resultVar0, resultVar1 } @@ -537,14 +525,13 @@ func (s *TimerLayerChannelStore) AutocompleteInTeamForSearch(teamId string, user resultVar0, resultVar1 := s.ChannelStore.AutocompleteInTeamForSearch(teamId, userId, term, includeDeleted) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.AutocompleteInTeamForSearch", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.AutocompleteInTeamForSearch", success, elapsed) } return resultVar0, resultVar1 } @@ -554,14 +541,13 @@ func (s *TimerLayerChannelStore) ClearAllCustomRoleAssignments() *model.AppError resultVar0 := s.ChannelStore.ClearAllCustomRoleAssignments() - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar0 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.ClearAllCustomRoleAssignments", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.ClearAllCustomRoleAssignments", success, elapsed) } return resultVar0 } @@ -571,14 +557,13 @@ func (s *TimerLayerChannelStore) ClearCaches() { s.ChannelStore.ClearCaches() - t := timemodule.Now() - elapsed := t.Sub(start) + 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, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.ClearCaches", success, elapsed) } return } @@ -588,14 +573,13 @@ func (s *TimerLayerChannelStore) CreateDirectChannel(userId *model.User, otherUs resultVar0, resultVar1 := s.ChannelStore.CreateDirectChannel(userId, otherUserId) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.CreateDirectChannel", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.CreateDirectChannel", success, elapsed) } return resultVar0, resultVar1 } @@ -605,14 +589,13 @@ func (s *TimerLayerChannelStore) Delete(channelId string, time int64) *model.App resultVar0 := s.ChannelStore.Delete(channelId, time) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar0 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.Delete", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.Delete", success, elapsed) } return resultVar0 } @@ -622,14 +605,13 @@ func (s *TimerLayerChannelStore) Get(id string, allowFromCache bool) (*model.Cha resultVar0, resultVar1 := s.ChannelStore.Get(id, allowFromCache) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.Get", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.Get", success, elapsed) } return resultVar0, resultVar1 } @@ -639,14 +621,13 @@ func (s *TimerLayerChannelStore) GetAll(teamId string) ([]*model.Channel, *model resultVar0, resultVar1 := s.ChannelStore.GetAll(teamId) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.GetAll", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.GetAll", success, elapsed) } return resultVar0, resultVar1 } @@ -656,14 +637,13 @@ func (s *TimerLayerChannelStore) GetAllChannelMembersForUser(userId string, allo resultVar0, resultVar1 := s.ChannelStore.GetAllChannelMembersForUser(userId, allowFromCache, includeDeleted) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.GetAllChannelMembersForUser", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.GetAllChannelMembersForUser", success, elapsed) } return resultVar0, resultVar1 } @@ -673,14 +653,13 @@ func (s *TimerLayerChannelStore) GetAllChannelMembersNotifyPropsForChannel(chann resultVar0, resultVar1 := s.ChannelStore.GetAllChannelMembersNotifyPropsForChannel(channelId, allowFromCache) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.GetAllChannelMembersNotifyPropsForChannel", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.GetAllChannelMembersNotifyPropsForChannel", success, elapsed) } return resultVar0, resultVar1 } @@ -690,14 +669,13 @@ func (s *TimerLayerChannelStore) GetAllChannels(page int, perPage int, opts Chan resultVar0, resultVar1 := s.ChannelStore.GetAllChannels(page, perPage, opts) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.GetAllChannels", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.GetAllChannels", success, elapsed) } return resultVar0, resultVar1 } @@ -707,14 +685,13 @@ func (s *TimerLayerChannelStore) GetAllChannelsCount(opts ChannelSearchOpts) (in resultVar0, resultVar1 := s.ChannelStore.GetAllChannelsCount(opts) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.GetAllChannelsCount", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.GetAllChannelsCount", success, elapsed) } return resultVar0, resultVar1 } @@ -724,14 +701,13 @@ func (s *TimerLayerChannelStore) GetAllChannelsForExportAfter(limit int, afterId resultVar0, resultVar1 := s.ChannelStore.GetAllChannelsForExportAfter(limit, afterId) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.GetAllChannelsForExportAfter", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.GetAllChannelsForExportAfter", success, elapsed) } return resultVar0, resultVar1 } @@ -741,14 +717,13 @@ func (s *TimerLayerChannelStore) GetAllDirectChannelsForExportAfter(limit int, a resultVar0, resultVar1 := s.ChannelStore.GetAllDirectChannelsForExportAfter(limit, afterId) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.GetAllDirectChannelsForExportAfter", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.GetAllDirectChannelsForExportAfter", success, elapsed) } return resultVar0, resultVar1 } @@ -758,14 +733,13 @@ func (s *TimerLayerChannelStore) GetByName(team_id string, name string, allowFro resultVar0, resultVar1 := s.ChannelStore.GetByName(team_id, name, allowFromCache) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.GetByName", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.GetByName", success, elapsed) } return resultVar0, resultVar1 } @@ -775,14 +749,13 @@ func (s *TimerLayerChannelStore) GetByNameIncludeDeleted(team_id string, name st resultVar0, resultVar1 := s.ChannelStore.GetByNameIncludeDeleted(team_id, name, allowFromCache) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.GetByNameIncludeDeleted", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.GetByNameIncludeDeleted", success, elapsed) } return resultVar0, resultVar1 } @@ -792,14 +765,13 @@ func (s *TimerLayerChannelStore) GetByNames(team_id string, names []string, allo resultVar0, resultVar1 := s.ChannelStore.GetByNames(team_id, names, allowFromCache) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.GetByNames", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.GetByNames", success, elapsed) } return resultVar0, resultVar1 } @@ -809,14 +781,13 @@ func (s *TimerLayerChannelStore) GetChannelCounts(teamId string, userId string) resultVar0, resultVar1 := s.ChannelStore.GetChannelCounts(teamId, userId) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.GetChannelCounts", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.GetChannelCounts", success, elapsed) } return resultVar0, resultVar1 } @@ -826,14 +797,13 @@ func (s *TimerLayerChannelStore) GetChannelMembersForExport(userId string, teamI resultVar0, resultVar1 := s.ChannelStore.GetChannelMembersForExport(userId, teamId) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.GetChannelMembersForExport", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.GetChannelMembersForExport", success, elapsed) } return resultVar0, resultVar1 } @@ -843,14 +813,13 @@ func (s *TimerLayerChannelStore) GetChannelMembersTimezones(channelId string) ([ resultVar0, resultVar1 := s.ChannelStore.GetChannelMembersTimezones(channelId) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.GetChannelMembersTimezones", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.GetChannelMembersTimezones", success, elapsed) } return resultVar0, resultVar1 } @@ -860,14 +829,13 @@ func (s *TimerLayerChannelStore) GetChannelUnread(channelId string, userId strin resultVar0, resultVar1 := s.ChannelStore.GetChannelUnread(channelId, userId) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.GetChannelUnread", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.GetChannelUnread", success, elapsed) } return resultVar0, resultVar1 } @@ -877,14 +845,13 @@ func (s *TimerLayerChannelStore) GetChannels(teamId string, userId string, inclu resultVar0, resultVar1 := s.ChannelStore.GetChannels(teamId, userId, includeDeleted) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.GetChannels", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.GetChannels", success, elapsed) } return resultVar0, resultVar1 } @@ -894,14 +861,13 @@ func (s *TimerLayerChannelStore) GetChannelsBatchForIndexing(startTime int64, en resultVar0, resultVar1 := s.ChannelStore.GetChannelsBatchForIndexing(startTime, endTime, limit) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.GetChannelsBatchForIndexing", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.GetChannelsBatchForIndexing", success, elapsed) } return resultVar0, resultVar1 } @@ -911,14 +877,13 @@ func (s *TimerLayerChannelStore) GetChannelsByIds(channelIds []string) ([]*model resultVar0, resultVar1 := s.ChannelStore.GetChannelsByIds(channelIds) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.GetChannelsByIds", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.GetChannelsByIds", success, elapsed) } return resultVar0, resultVar1 } @@ -928,14 +893,13 @@ func (s *TimerLayerChannelStore) GetChannelsByScheme(schemeId string, offset int resultVar0, resultVar1 := s.ChannelStore.GetChannelsByScheme(schemeId, offset, limit) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.GetChannelsByScheme", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.GetChannelsByScheme", success, elapsed) } return resultVar0, resultVar1 } @@ -945,14 +909,13 @@ func (s *TimerLayerChannelStore) GetDeleted(team_id string, offset int, limit in resultVar0, resultVar1 := s.ChannelStore.GetDeleted(team_id, offset, limit) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.GetDeleted", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.GetDeleted", success, elapsed) } return resultVar0, resultVar1 } @@ -962,14 +925,13 @@ func (s *TimerLayerChannelStore) GetDeletedByName(team_id string, name string) ( resultVar0, resultVar1 := s.ChannelStore.GetDeletedByName(team_id, name) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.GetDeletedByName", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.GetDeletedByName", success, elapsed) } return resultVar0, resultVar1 } @@ -979,14 +941,13 @@ func (s *TimerLayerChannelStore) GetForPost(postId string) (*model.Channel, *mod resultVar0, resultVar1 := s.ChannelStore.GetForPost(postId) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.GetForPost", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.GetForPost", success, elapsed) } return resultVar0, resultVar1 } @@ -996,14 +957,13 @@ func (s *TimerLayerChannelStore) GetFromMaster(id string) (*model.Channel, *mode resultVar0, resultVar1 := s.ChannelStore.GetFromMaster(id) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.GetFromMaster", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.GetFromMaster", success, elapsed) } return resultVar0, resultVar1 } @@ -1013,14 +973,13 @@ func (s *TimerLayerChannelStore) GetGuestCount(channelId string, allowFromCache resultVar0, resultVar1 := s.ChannelStore.GetGuestCount(channelId, allowFromCache) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.GetGuestCount", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.GetGuestCount", success, elapsed) } return resultVar0, resultVar1 } @@ -1030,14 +989,13 @@ func (s *TimerLayerChannelStore) GetGuestCountFromCache(channelId string) int64 resultVar0 := s.ChannelStore.GetGuestCountFromCache(channelId) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if true { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.GetGuestCountFromCache", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.GetGuestCountFromCache", success, elapsed) } return resultVar0 } @@ -1047,14 +1005,13 @@ func (s *TimerLayerChannelStore) GetMember(channelId string, userId string) (*mo resultVar0, resultVar1 := s.ChannelStore.GetMember(channelId, userId) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.GetMember", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.GetMember", success, elapsed) } return resultVar0, resultVar1 } @@ -1064,14 +1021,13 @@ func (s *TimerLayerChannelStore) GetMemberCount(channelId string, allowFromCache resultVar0, resultVar1 := s.ChannelStore.GetMemberCount(channelId, allowFromCache) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.GetMemberCount", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.GetMemberCount", success, elapsed) } return resultVar0, resultVar1 } @@ -1081,14 +1037,13 @@ func (s *TimerLayerChannelStore) GetMemberCountFromCache(channelId string) int64 resultVar0 := s.ChannelStore.GetMemberCountFromCache(channelId) - t := timemodule.Now() - elapsed := t.Sub(start) + 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, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.GetMemberCountFromCache", success, elapsed) } return resultVar0 } @@ -1098,14 +1053,13 @@ func (s *TimerLayerChannelStore) GetMemberForPost(postId string, userId string) resultVar0, resultVar1 := s.ChannelStore.GetMemberForPost(postId, userId) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.GetMemberForPost", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.GetMemberForPost", success, elapsed) } return resultVar0, resultVar1 } @@ -1115,14 +1069,13 @@ func (s *TimerLayerChannelStore) GetMembers(channelId string, offset int, limit resultVar0, resultVar1 := s.ChannelStore.GetMembers(channelId, offset, limit) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.GetMembers", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.GetMembers", success, elapsed) } return resultVar0, resultVar1 } @@ -1132,14 +1085,13 @@ func (s *TimerLayerChannelStore) GetMembersByIds(channelId string, userIds []str resultVar0, resultVar1 := s.ChannelStore.GetMembersByIds(channelId, userIds) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.GetMembersByIds", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.GetMembersByIds", success, elapsed) } return resultVar0, resultVar1 } @@ -1149,14 +1101,13 @@ func (s *TimerLayerChannelStore) GetMembersForUser(teamId string, userId string) resultVar0, resultVar1 := s.ChannelStore.GetMembersForUser(teamId, userId) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.GetMembersForUser", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.GetMembersForUser", success, elapsed) } return resultVar0, resultVar1 } @@ -1166,14 +1117,13 @@ func (s *TimerLayerChannelStore) GetMembersForUserWithPagination(teamId string, resultVar0, resultVar1 := s.ChannelStore.GetMembersForUserWithPagination(teamId, userId, page, perPage) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.GetMembersForUserWithPagination", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.GetMembersForUserWithPagination", success, elapsed) } return resultVar0, resultVar1 } @@ -1183,14 +1133,13 @@ func (s *TimerLayerChannelStore) GetMoreChannels(teamId string, userId string, o resultVar0, resultVar1 := s.ChannelStore.GetMoreChannels(teamId, userId, offset, limit) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.GetMoreChannels", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.GetMoreChannels", success, elapsed) } return resultVar0, resultVar1 } @@ -1200,14 +1149,13 @@ func (s *TimerLayerChannelStore) GetPinnedPostCount(channelId string, allowFromC resultVar0, resultVar1 := s.ChannelStore.GetPinnedPostCount(channelId, allowFromCache) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.GetPinnedPostCount", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.GetPinnedPostCount", success, elapsed) } return resultVar0, resultVar1 } @@ -1217,14 +1165,13 @@ func (s *TimerLayerChannelStore) GetPinnedPostCountFromCache(channelId string) i resultVar0 := s.ChannelStore.GetPinnedPostCountFromCache(channelId) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if true { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.GetPinnedPostCountFromCache", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.GetPinnedPostCountFromCache", success, elapsed) } return resultVar0 } @@ -1234,14 +1181,13 @@ func (s *TimerLayerChannelStore) GetPinnedPosts(channelId string) (*model.PostLi resultVar0, resultVar1 := s.ChannelStore.GetPinnedPosts(channelId) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.GetPinnedPosts", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.GetPinnedPosts", success, elapsed) } return resultVar0, resultVar1 } @@ -1251,14 +1197,13 @@ func (s *TimerLayerChannelStore) GetPublicChannelsByIdsForTeam(teamId string, ch resultVar0, resultVar1 := s.ChannelStore.GetPublicChannelsByIdsForTeam(teamId, channelIds) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.GetPublicChannelsByIdsForTeam", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.GetPublicChannelsByIdsForTeam", success, elapsed) } return resultVar0, resultVar1 } @@ -1268,14 +1213,13 @@ func (s *TimerLayerChannelStore) GetPublicChannelsForTeam(teamId string, offset resultVar0, resultVar1 := s.ChannelStore.GetPublicChannelsForTeam(teamId, offset, limit) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.GetPublicChannelsForTeam", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.GetPublicChannelsForTeam", success, elapsed) } return resultVar0, resultVar1 } @@ -1285,14 +1229,13 @@ func (s *TimerLayerChannelStore) GetTeamChannels(teamId string) (*model.ChannelL resultVar0, resultVar1 := s.ChannelStore.GetTeamChannels(teamId) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.GetTeamChannels", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.GetTeamChannels", success, elapsed) } return resultVar0, resultVar1 } @@ -1302,14 +1245,13 @@ func (s *TimerLayerChannelStore) IncrementMentionCount(channelId string, userId resultVar0 := s.ChannelStore.IncrementMentionCount(channelId, userId) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar0 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.IncrementMentionCount", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.IncrementMentionCount", success, elapsed) } return resultVar0 } @@ -1319,14 +1261,13 @@ func (s *TimerLayerChannelStore) InvalidateAllChannelMembersForUser(userId strin s.ChannelStore.InvalidateAllChannelMembersForUser(userId) - t := timemodule.Now() - elapsed := t.Sub(start) + 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, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.InvalidateAllChannelMembersForUser", success, elapsed) } return } @@ -1336,14 +1277,13 @@ func (s *TimerLayerChannelStore) InvalidateCacheForChannelMembersNotifyProps(cha s.ChannelStore.InvalidateCacheForChannelMembersNotifyProps(channelId) - t := timemodule.Now() - elapsed := t.Sub(start) + 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, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.InvalidateCacheForChannelMembersNotifyProps", success, elapsed) } return } @@ -1353,14 +1293,13 @@ func (s *TimerLayerChannelStore) InvalidateChannel(id string) { s.ChannelStore.InvalidateChannel(id) - t := timemodule.Now() - elapsed := t.Sub(start) + 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, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.InvalidateChannel", success, elapsed) } return } @@ -1370,14 +1309,13 @@ func (s *TimerLayerChannelStore) InvalidateChannelByName(teamId string, name str s.ChannelStore.InvalidateChannelByName(teamId, name) - t := timemodule.Now() - elapsed := t.Sub(start) + 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, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.InvalidateChannelByName", success, elapsed) } return } @@ -1387,14 +1325,13 @@ func (s *TimerLayerChannelStore) InvalidateGuestCount(channelId string) { s.ChannelStore.InvalidateGuestCount(channelId) - t := timemodule.Now() - elapsed := t.Sub(start) + 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, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.InvalidateGuestCount", success, elapsed) } return } @@ -1404,14 +1341,13 @@ func (s *TimerLayerChannelStore) InvalidateMemberCount(channelId string) { s.ChannelStore.InvalidateMemberCount(channelId) - t := timemodule.Now() - elapsed := t.Sub(start) + 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, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.InvalidateMemberCount", success, elapsed) } return } @@ -1421,14 +1357,13 @@ func (s *TimerLayerChannelStore) InvalidatePinnedPostCount(channelId string) { s.ChannelStore.InvalidatePinnedPostCount(channelId) - t := timemodule.Now() - elapsed := t.Sub(start) + 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, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.InvalidatePinnedPostCount", success, elapsed) } return } @@ -1438,14 +1373,13 @@ func (s *TimerLayerChannelStore) IsUserInChannelUseCache(userId string, channelI resultVar0 := s.ChannelStore.IsUserInChannelUseCache(userId, channelId) - t := timemodule.Now() - elapsed := t.Sub(start) + 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, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.IsUserInChannelUseCache", success, elapsed) } return resultVar0 } @@ -1455,14 +1389,13 @@ func (s *TimerLayerChannelStore) MigrateChannelMembers(fromChannelId string, fro resultVar0, resultVar1 := s.ChannelStore.MigrateChannelMembers(fromChannelId, fromUserId) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.MigrateChannelMembers", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.MigrateChannelMembers", success, elapsed) } return resultVar0, resultVar1 } @@ -1472,14 +1405,13 @@ func (s *TimerLayerChannelStore) MigratePublicChannels() error { resultVar0 := s.ChannelStore.MigratePublicChannels() - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if true { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.MigratePublicChannels", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.MigratePublicChannels", success, elapsed) } return resultVar0 } @@ -1489,14 +1421,13 @@ func (s *TimerLayerChannelStore) PermanentDelete(channelId string) *model.AppErr resultVar0 := s.ChannelStore.PermanentDelete(channelId) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar0 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.PermanentDelete", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.PermanentDelete", success, elapsed) } return resultVar0 } @@ -1506,14 +1437,13 @@ func (s *TimerLayerChannelStore) PermanentDeleteByTeam(teamId string) *model.App resultVar0 := s.ChannelStore.PermanentDeleteByTeam(teamId) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar0 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.PermanentDeleteByTeam", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.PermanentDeleteByTeam", success, elapsed) } return resultVar0 } @@ -1523,14 +1453,13 @@ func (s *TimerLayerChannelStore) PermanentDeleteMembersByChannel(channelId strin resultVar0 := s.ChannelStore.PermanentDeleteMembersByChannel(channelId) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar0 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.PermanentDeleteMembersByChannel", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.PermanentDeleteMembersByChannel", success, elapsed) } return resultVar0 } @@ -1540,14 +1469,13 @@ func (s *TimerLayerChannelStore) PermanentDeleteMembersByUser(userId string) *mo resultVar0 := s.ChannelStore.PermanentDeleteMembersByUser(userId) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar0 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.PermanentDeleteMembersByUser", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.PermanentDeleteMembersByUser", success, elapsed) } return resultVar0 } @@ -1557,14 +1485,13 @@ func (s *TimerLayerChannelStore) RemoveAllDeactivatedMembers(channelId string) * resultVar0 := s.ChannelStore.RemoveAllDeactivatedMembers(channelId) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar0 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.RemoveAllDeactivatedMembers", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.RemoveAllDeactivatedMembers", success, elapsed) } return resultVar0 } @@ -1574,14 +1501,13 @@ func (s *TimerLayerChannelStore) RemoveMember(channelId string, userId string) * resultVar0 := s.ChannelStore.RemoveMember(channelId, userId) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar0 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.RemoveMember", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.RemoveMember", success, elapsed) } return resultVar0 } @@ -1591,14 +1517,13 @@ func (s *TimerLayerChannelStore) ResetAllChannelSchemes() *model.AppError { resultVar0 := s.ChannelStore.ResetAllChannelSchemes() - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar0 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.ResetAllChannelSchemes", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.ResetAllChannelSchemes", success, elapsed) } return resultVar0 } @@ -1608,14 +1533,13 @@ func (s *TimerLayerChannelStore) Restore(channelId string, time int64) *model.Ap resultVar0 := s.ChannelStore.Restore(channelId, time) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar0 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.Restore", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.Restore", success, elapsed) } return resultVar0 } @@ -1625,14 +1549,13 @@ func (s *TimerLayerChannelStore) Save(channel *model.Channel, maxChannelsPerTeam resultVar0, resultVar1 := s.ChannelStore.Save(channel, maxChannelsPerTeam) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.Save", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.Save", success, elapsed) } return resultVar0, resultVar1 } @@ -1642,14 +1565,13 @@ func (s *TimerLayerChannelStore) SaveDirectChannel(channel *model.Channel, membe resultVar0, resultVar1 := s.ChannelStore.SaveDirectChannel(channel, member1, member2) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.SaveDirectChannel", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.SaveDirectChannel", success, elapsed) } return resultVar0, resultVar1 } @@ -1659,14 +1581,13 @@ func (s *TimerLayerChannelStore) SaveMember(member *model.ChannelMember) (*model resultVar0, resultVar1 := s.ChannelStore.SaveMember(member) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.SaveMember", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.SaveMember", success, elapsed) } return resultVar0, resultVar1 } @@ -1676,14 +1597,13 @@ func (s *TimerLayerChannelStore) SearchAllChannels(term string, opts ChannelSear resultVar0, resultVar1 := s.ChannelStore.SearchAllChannels(term, opts) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.SearchAllChannels", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.SearchAllChannels", success, elapsed) } return resultVar0, resultVar1 } @@ -1693,14 +1613,13 @@ func (s *TimerLayerChannelStore) SearchForUserInTeam(userId string, teamId strin resultVar0, resultVar1 := s.ChannelStore.SearchForUserInTeam(userId, teamId, term, includeDeleted) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.SearchForUserInTeam", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.SearchForUserInTeam", success, elapsed) } return resultVar0, resultVar1 } @@ -1710,14 +1629,13 @@ func (s *TimerLayerChannelStore) SearchGroupChannels(userId string, term string) resultVar0, resultVar1 := s.ChannelStore.SearchGroupChannels(userId, term) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.SearchGroupChannels", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.SearchGroupChannels", success, elapsed) } return resultVar0, resultVar1 } @@ -1727,14 +1645,13 @@ func (s *TimerLayerChannelStore) SearchInTeam(teamId string, term string, includ resultVar0, resultVar1 := s.ChannelStore.SearchInTeam(teamId, term, includeDeleted) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.SearchInTeam", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.SearchInTeam", success, elapsed) } return resultVar0, resultVar1 } @@ -1744,14 +1661,13 @@ func (s *TimerLayerChannelStore) SearchMore(userId string, teamId string, term s resultVar0, resultVar1 := s.ChannelStore.SearchMore(userId, teamId, term) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.SearchMore", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.SearchMore", success, elapsed) } return resultVar0, resultVar1 } @@ -1761,14 +1677,13 @@ func (s *TimerLayerChannelStore) SetDeleteAt(channelId string, deleteAt int64, u resultVar0 := s.ChannelStore.SetDeleteAt(channelId, deleteAt, updateAt) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar0 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.SetDeleteAt", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.SetDeleteAt", success, elapsed) } return resultVar0 } @@ -1778,14 +1693,13 @@ func (s *TimerLayerChannelStore) Update(channel *model.Channel) (*model.Channel, resultVar0, resultVar1 := s.ChannelStore.Update(channel) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.Update", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.Update", success, elapsed) } return resultVar0, resultVar1 } @@ -1795,14 +1709,13 @@ func (s *TimerLayerChannelStore) UpdateLastViewedAt(channelIds []string, userId resultVar0, resultVar1 := s.ChannelStore.UpdateLastViewedAt(channelIds, userId) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.UpdateLastViewedAt", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.UpdateLastViewedAt", success, elapsed) } return resultVar0, resultVar1 } @@ -1812,14 +1725,13 @@ func (s *TimerLayerChannelStore) UpdateMember(member *model.ChannelMember) (*mod resultVar0, resultVar1 := s.ChannelStore.UpdateMember(member) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.UpdateMember", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.UpdateMember", success, elapsed) } return resultVar0, resultVar1 } @@ -1829,14 +1741,13 @@ func (s *TimerLayerChannelStore) UserBelongsToChannels(userId string, channelIds resultVar0, resultVar1 := s.ChannelStore.UserBelongsToChannels(userId, channelIds) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.UserBelongsToChannels", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.UserBelongsToChannels", success, elapsed) } return resultVar0, resultVar1 } @@ -1846,14 +1757,13 @@ func (s *TimerLayerChannelMemberHistoryStore) GetUsersInChannelDuring(startTime resultVar0, resultVar1 := s.ChannelMemberHistoryStore.GetUsersInChannelDuring(startTime, endTime, channelId) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("ChannelMemberHistoryStore.GetUsersInChannelDuring", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("ChannelMemberHistoryStore.GetUsersInChannelDuring", success, elapsed) } return resultVar0, resultVar1 } @@ -1863,14 +1773,13 @@ func (s *TimerLayerChannelMemberHistoryStore) LogJoinEvent(userId string, channe resultVar0 := s.ChannelMemberHistoryStore.LogJoinEvent(userId, channelId, joinTime) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar0 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("ChannelMemberHistoryStore.LogJoinEvent", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("ChannelMemberHistoryStore.LogJoinEvent", success, elapsed) } return resultVar0 } @@ -1880,14 +1789,13 @@ func (s *TimerLayerChannelMemberHistoryStore) LogLeaveEvent(userId string, chann resultVar0 := s.ChannelMemberHistoryStore.LogLeaveEvent(userId, channelId, leaveTime) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar0 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("ChannelMemberHistoryStore.LogLeaveEvent", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("ChannelMemberHistoryStore.LogLeaveEvent", success, elapsed) } return resultVar0 } @@ -1897,14 +1805,13 @@ func (s *TimerLayerChannelMemberHistoryStore) PermanentDeleteBatch(endTime int64 resultVar0, resultVar1 := s.ChannelMemberHistoryStore.PermanentDeleteBatch(endTime, limit) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("ChannelMemberHistoryStore.PermanentDeleteBatch", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("ChannelMemberHistoryStore.PermanentDeleteBatch", success, elapsed) } return resultVar0, resultVar1 } @@ -1914,14 +1821,13 @@ func (s *TimerLayerClusterDiscoveryStore) Cleanup() *model.AppError { resultVar0 := s.ClusterDiscoveryStore.Cleanup() - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar0 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("ClusterDiscoveryStore.Cleanup", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("ClusterDiscoveryStore.Cleanup", success, elapsed) } return resultVar0 } @@ -1931,14 +1837,13 @@ func (s *TimerLayerClusterDiscoveryStore) Delete(discovery *model.ClusterDiscove resultVar0, resultVar1 := s.ClusterDiscoveryStore.Delete(discovery) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("ClusterDiscoveryStore.Delete", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("ClusterDiscoveryStore.Delete", success, elapsed) } return resultVar0, resultVar1 } @@ -1948,14 +1853,13 @@ func (s *TimerLayerClusterDiscoveryStore) Exists(discovery *model.ClusterDiscove resultVar0, resultVar1 := s.ClusterDiscoveryStore.Exists(discovery) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("ClusterDiscoveryStore.Exists", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("ClusterDiscoveryStore.Exists", success, elapsed) } return resultVar0, resultVar1 } @@ -1965,14 +1869,13 @@ func (s *TimerLayerClusterDiscoveryStore) GetAll(discoveryType string, clusterNa resultVar0, resultVar1 := s.ClusterDiscoveryStore.GetAll(discoveryType, clusterName) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("ClusterDiscoveryStore.GetAll", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("ClusterDiscoveryStore.GetAll", success, elapsed) } return resultVar0, resultVar1 } @@ -1982,14 +1885,13 @@ func (s *TimerLayerClusterDiscoveryStore) Save(discovery *model.ClusterDiscovery resultVar0 := s.ClusterDiscoveryStore.Save(discovery) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar0 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("ClusterDiscoveryStore.Save", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("ClusterDiscoveryStore.Save", success, elapsed) } return resultVar0 } @@ -1999,14 +1901,13 @@ func (s *TimerLayerClusterDiscoveryStore) SetLastPingAt(discovery *model.Cluster resultVar0 := s.ClusterDiscoveryStore.SetLastPingAt(discovery) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar0 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("ClusterDiscoveryStore.SetLastPingAt", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("ClusterDiscoveryStore.SetLastPingAt", success, elapsed) } return resultVar0 } @@ -2016,14 +1917,13 @@ func (s *TimerLayerCommandStore) AnalyticsCommandCount(teamId string) (int64, *m resultVar0, resultVar1 := s.CommandStore.AnalyticsCommandCount(teamId) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("CommandStore.AnalyticsCommandCount", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("CommandStore.AnalyticsCommandCount", success, elapsed) } return resultVar0, resultVar1 } @@ -2033,14 +1933,13 @@ func (s *TimerLayerCommandStore) Delete(commandId string, time int64) *model.App resultVar0 := s.CommandStore.Delete(commandId, time) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar0 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("CommandStore.Delete", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("CommandStore.Delete", success, elapsed) } return resultVar0 } @@ -2050,14 +1949,13 @@ func (s *TimerLayerCommandStore) Get(id string) (*model.Command, *model.AppError resultVar0, resultVar1 := s.CommandStore.Get(id) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("CommandStore.Get", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("CommandStore.Get", success, elapsed) } return resultVar0, resultVar1 } @@ -2067,14 +1965,13 @@ func (s *TimerLayerCommandStore) GetByTeam(teamId string) ([]*model.Command, *mo resultVar0, resultVar1 := s.CommandStore.GetByTeam(teamId) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("CommandStore.GetByTeam", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("CommandStore.GetByTeam", success, elapsed) } return resultVar0, resultVar1 } @@ -2084,14 +1981,13 @@ func (s *TimerLayerCommandStore) GetByTrigger(teamId string, trigger string) (*m resultVar0, resultVar1 := s.CommandStore.GetByTrigger(teamId, trigger) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("CommandStore.GetByTrigger", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("CommandStore.GetByTrigger", success, elapsed) } return resultVar0, resultVar1 } @@ -2101,14 +1997,13 @@ func (s *TimerLayerCommandStore) PermanentDeleteByTeam(teamId string) *model.App resultVar0 := s.CommandStore.PermanentDeleteByTeam(teamId) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar0 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("CommandStore.PermanentDeleteByTeam", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("CommandStore.PermanentDeleteByTeam", success, elapsed) } return resultVar0 } @@ -2118,14 +2013,13 @@ func (s *TimerLayerCommandStore) PermanentDeleteByUser(userId string) *model.App resultVar0 := s.CommandStore.PermanentDeleteByUser(userId) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar0 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("CommandStore.PermanentDeleteByUser", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("CommandStore.PermanentDeleteByUser", success, elapsed) } return resultVar0 } @@ -2135,14 +2029,13 @@ func (s *TimerLayerCommandStore) Save(webhook *model.Command) (*model.Command, * resultVar0, resultVar1 := s.CommandStore.Save(webhook) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("CommandStore.Save", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("CommandStore.Save", success, elapsed) } return resultVar0, resultVar1 } @@ -2152,14 +2045,13 @@ func (s *TimerLayerCommandStore) Update(hook *model.Command) (*model.Command, *m resultVar0, resultVar1 := s.CommandStore.Update(hook) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("CommandStore.Update", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("CommandStore.Update", success, elapsed) } return resultVar0, resultVar1 } @@ -2169,14 +2061,13 @@ func (s *TimerLayerCommandWebhookStore) Cleanup() { s.CommandWebhookStore.Cleanup() - t := timemodule.Now() - elapsed := t.Sub(start) + 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, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("CommandWebhookStore.Cleanup", success, elapsed) } return } @@ -2186,14 +2077,13 @@ func (s *TimerLayerCommandWebhookStore) Get(id string) (*model.CommandWebhook, * resultVar0, resultVar1 := s.CommandWebhookStore.Get(id) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("CommandWebhookStore.Get", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("CommandWebhookStore.Get", success, elapsed) } return resultVar0, resultVar1 } @@ -2203,14 +2093,13 @@ func (s *TimerLayerCommandWebhookStore) Save(webhook *model.CommandWebhook) (*mo resultVar0, resultVar1 := s.CommandWebhookStore.Save(webhook) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("CommandWebhookStore.Save", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("CommandWebhookStore.Save", success, elapsed) } return resultVar0, resultVar1 } @@ -2220,14 +2109,13 @@ func (s *TimerLayerCommandWebhookStore) TryUse(id string, limit int) *model.AppE resultVar0 := s.CommandWebhookStore.TryUse(id, limit) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar0 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("CommandWebhookStore.TryUse", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("CommandWebhookStore.TryUse", success, elapsed) } return resultVar0 } @@ -2237,14 +2125,13 @@ func (s *TimerLayerComplianceStore) ComplianceExport(compliance *model.Complianc resultVar0, resultVar1 := s.ComplianceStore.ComplianceExport(compliance) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("ComplianceStore.ComplianceExport", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("ComplianceStore.ComplianceExport", success, elapsed) } return resultVar0, resultVar1 } @@ -2254,14 +2141,13 @@ func (s *TimerLayerComplianceStore) Get(id string) (*model.Compliance, *model.Ap resultVar0, resultVar1 := s.ComplianceStore.Get(id) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("ComplianceStore.Get", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("ComplianceStore.Get", success, elapsed) } return resultVar0, resultVar1 } @@ -2271,14 +2157,13 @@ func (s *TimerLayerComplianceStore) GetAll(offset int, limit int) (model.Complia resultVar0, resultVar1 := s.ComplianceStore.GetAll(offset, limit) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("ComplianceStore.GetAll", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("ComplianceStore.GetAll", success, elapsed) } return resultVar0, resultVar1 } @@ -2288,14 +2173,13 @@ func (s *TimerLayerComplianceStore) MessageExport(after int64, limit int) ([]*mo resultVar0, resultVar1 := s.ComplianceStore.MessageExport(after, limit) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("ComplianceStore.MessageExport", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("ComplianceStore.MessageExport", success, elapsed) } return resultVar0, resultVar1 } @@ -2305,14 +2189,13 @@ func (s *TimerLayerComplianceStore) Save(compliance *model.Compliance) (*model.C resultVar0, resultVar1 := s.ComplianceStore.Save(compliance) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("ComplianceStore.Save", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("ComplianceStore.Save", success, elapsed) } return resultVar0, resultVar1 } @@ -2322,14 +2205,13 @@ func (s *TimerLayerComplianceStore) Update(compliance *model.Compliance) (*model resultVar0, resultVar1 := s.ComplianceStore.Update(compliance) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("ComplianceStore.Update", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("ComplianceStore.Update", success, elapsed) } return resultVar0, resultVar1 } @@ -2339,14 +2221,13 @@ func (s *TimerLayerEmojiStore) Delete(emoji *model.Emoji, time int64) *model.App resultVar0 := s.EmojiStore.Delete(emoji, time) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar0 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("EmojiStore.Delete", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("EmojiStore.Delete", success, elapsed) } return resultVar0 } @@ -2356,14 +2237,13 @@ func (s *TimerLayerEmojiStore) Get(id string, allowFromCache bool) (*model.Emoji resultVar0, resultVar1 := s.EmojiStore.Get(id, allowFromCache) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("EmojiStore.Get", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("EmojiStore.Get", success, elapsed) } return resultVar0, resultVar1 } @@ -2373,14 +2253,13 @@ func (s *TimerLayerEmojiStore) GetByName(name string, allowFromCache bool) (*mod resultVar0, resultVar1 := s.EmojiStore.GetByName(name, allowFromCache) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("EmojiStore.GetByName", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("EmojiStore.GetByName", success, elapsed) } return resultVar0, resultVar1 } @@ -2390,14 +2269,13 @@ func (s *TimerLayerEmojiStore) GetList(offset int, limit int, sort string) ([]*m resultVar0, resultVar1 := s.EmojiStore.GetList(offset, limit, sort) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("EmojiStore.GetList", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("EmojiStore.GetList", success, elapsed) } return resultVar0, resultVar1 } @@ -2407,14 +2285,13 @@ func (s *TimerLayerEmojiStore) GetMultipleByName(names []string) ([]*model.Emoji resultVar0, resultVar1 := s.EmojiStore.GetMultipleByName(names) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("EmojiStore.GetMultipleByName", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("EmojiStore.GetMultipleByName", success, elapsed) } return resultVar0, resultVar1 } @@ -2424,14 +2301,13 @@ func (s *TimerLayerEmojiStore) Save(emoji *model.Emoji) (*model.Emoji, *model.Ap resultVar0, resultVar1 := s.EmojiStore.Save(emoji) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("EmojiStore.Save", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("EmojiStore.Save", success, elapsed) } return resultVar0, resultVar1 } @@ -2441,14 +2317,13 @@ func (s *TimerLayerEmojiStore) Search(name string, prefixOnly bool, limit int) ( resultVar0, resultVar1 := s.EmojiStore.Search(name, prefixOnly, limit) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("EmojiStore.Search", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("EmojiStore.Search", success, elapsed) } return resultVar0, resultVar1 } @@ -2458,14 +2333,13 @@ func (s *TimerLayerFileInfoStore) AttachToPost(fileId string, postId string, cre resultVar0 := s.FileInfoStore.AttachToPost(fileId, postId, creatorId) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar0 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("FileInfoStore.AttachToPost", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("FileInfoStore.AttachToPost", success, elapsed) } return resultVar0 } @@ -2475,14 +2349,13 @@ func (s *TimerLayerFileInfoStore) ClearCaches() { s.FileInfoStore.ClearCaches() - t := timemodule.Now() - elapsed := t.Sub(start) + 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, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("FileInfoStore.ClearCaches", success, elapsed) } return } @@ -2492,14 +2365,13 @@ func (s *TimerLayerFileInfoStore) DeleteForPost(postId string) (string, *model.A resultVar0, resultVar1 := s.FileInfoStore.DeleteForPost(postId) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("FileInfoStore.DeleteForPost", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("FileInfoStore.DeleteForPost", success, elapsed) } return resultVar0, resultVar1 } @@ -2509,14 +2381,13 @@ func (s *TimerLayerFileInfoStore) Get(id string) (*model.FileInfo, *model.AppErr resultVar0, resultVar1 := s.FileInfoStore.Get(id) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("FileInfoStore.Get", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("FileInfoStore.Get", success, elapsed) } return resultVar0, resultVar1 } @@ -2526,14 +2397,13 @@ func (s *TimerLayerFileInfoStore) GetByPath(path string) (*model.FileInfo, *mode resultVar0, resultVar1 := s.FileInfoStore.GetByPath(path) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("FileInfoStore.GetByPath", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("FileInfoStore.GetByPath", success, elapsed) } return resultVar0, resultVar1 } @@ -2543,14 +2413,13 @@ func (s *TimerLayerFileInfoStore) GetForPost(postId string, readFromMaster bool, resultVar0, resultVar1 := s.FileInfoStore.GetForPost(postId, readFromMaster, includeDeleted, allowFromCache) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("FileInfoStore.GetForPost", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("FileInfoStore.GetForPost", success, elapsed) } return resultVar0, resultVar1 } @@ -2560,14 +2429,13 @@ func (s *TimerLayerFileInfoStore) GetForUser(userId string) ([]*model.FileInfo, resultVar0, resultVar1 := s.FileInfoStore.GetForUser(userId) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("FileInfoStore.GetForUser", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("FileInfoStore.GetForUser", success, elapsed) } return resultVar0, resultVar1 } @@ -2577,14 +2445,13 @@ func (s *TimerLayerFileInfoStore) InvalidateFileInfosForPostCache(postId string) s.FileInfoStore.InvalidateFileInfosForPostCache(postId) - t := timemodule.Now() - elapsed := t.Sub(start) + 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, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("FileInfoStore.InvalidateFileInfosForPostCache", success, elapsed) } return } @@ -2594,14 +2461,13 @@ func (s *TimerLayerFileInfoStore) PermanentDelete(fileId string) *model.AppError resultVar0 := s.FileInfoStore.PermanentDelete(fileId) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar0 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("FileInfoStore.PermanentDelete", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("FileInfoStore.PermanentDelete", success, elapsed) } return resultVar0 } @@ -2611,14 +2477,13 @@ func (s *TimerLayerFileInfoStore) PermanentDeleteBatch(endTime int64, limit int6 resultVar0, resultVar1 := s.FileInfoStore.PermanentDeleteBatch(endTime, limit) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("FileInfoStore.PermanentDeleteBatch", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("FileInfoStore.PermanentDeleteBatch", success, elapsed) } return resultVar0, resultVar1 } @@ -2628,14 +2493,13 @@ func (s *TimerLayerFileInfoStore) PermanentDeleteByUser(userId string) (int64, * resultVar0, resultVar1 := s.FileInfoStore.PermanentDeleteByUser(userId) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("FileInfoStore.PermanentDeleteByUser", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("FileInfoStore.PermanentDeleteByUser", success, elapsed) } return resultVar0, resultVar1 } @@ -2645,14 +2509,13 @@ func (s *TimerLayerFileInfoStore) Save(info *model.FileInfo) (*model.FileInfo, * resultVar0, resultVar1 := s.FileInfoStore.Save(info) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("FileInfoStore.Save", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("FileInfoStore.Save", success, elapsed) } return resultVar0, resultVar1 } @@ -2662,14 +2525,13 @@ func (s *TimerLayerGroupStore) ChannelMembersMinusGroupMembers(channelID string, resultVar0, resultVar1 := s.GroupStore.ChannelMembersMinusGroupMembers(channelID, groupIDs, page, perPage) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("GroupStore.ChannelMembersMinusGroupMembers", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("GroupStore.ChannelMembersMinusGroupMembers", success, elapsed) } return resultVar0, resultVar1 } @@ -2679,14 +2541,13 @@ func (s *TimerLayerGroupStore) ChannelMembersToAdd(since int64) ([]*model.UserCh resultVar0, resultVar1 := s.GroupStore.ChannelMembersToAdd(since) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("GroupStore.ChannelMembersToAdd", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("GroupStore.ChannelMembersToAdd", success, elapsed) } return resultVar0, resultVar1 } @@ -2696,14 +2557,13 @@ func (s *TimerLayerGroupStore) ChannelMembersToRemove() ([]*model.ChannelMember, resultVar0, resultVar1 := s.GroupStore.ChannelMembersToRemove() - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("GroupStore.ChannelMembersToRemove", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("GroupStore.ChannelMembersToRemove", success, elapsed) } return resultVar0, resultVar1 } @@ -2713,14 +2573,13 @@ func (s *TimerLayerGroupStore) CountChannelMembersMinusGroupMembers(channelID st resultVar0, resultVar1 := s.GroupStore.CountChannelMembersMinusGroupMembers(channelID, groupIDs) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("GroupStore.CountChannelMembersMinusGroupMembers", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("GroupStore.CountChannelMembersMinusGroupMembers", success, elapsed) } return resultVar0, resultVar1 } @@ -2730,14 +2589,13 @@ func (s *TimerLayerGroupStore) CountGroupsByChannel(channelId string, opts model resultVar0, resultVar1 := s.GroupStore.CountGroupsByChannel(channelId, opts) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("GroupStore.CountGroupsByChannel", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("GroupStore.CountGroupsByChannel", success, elapsed) } return resultVar0, resultVar1 } @@ -2747,14 +2605,13 @@ func (s *TimerLayerGroupStore) CountGroupsByTeam(teamId string, opts model.Group resultVar0, resultVar1 := s.GroupStore.CountGroupsByTeam(teamId, opts) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("GroupStore.CountGroupsByTeam", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("GroupStore.CountGroupsByTeam", success, elapsed) } return resultVar0, resultVar1 } @@ -2764,14 +2621,13 @@ func (s *TimerLayerGroupStore) CountTeamMembersMinusGroupMembers(teamID string, resultVar0, resultVar1 := s.GroupStore.CountTeamMembersMinusGroupMembers(teamID, groupIDs) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("GroupStore.CountTeamMembersMinusGroupMembers", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("GroupStore.CountTeamMembersMinusGroupMembers", success, elapsed) } return resultVar0, resultVar1 } @@ -2781,14 +2637,13 @@ func (s *TimerLayerGroupStore) Create(group *model.Group) (*model.Group, *model. resultVar0, resultVar1 := s.GroupStore.Create(group) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("GroupStore.Create", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("GroupStore.Create", success, elapsed) } return resultVar0, resultVar1 } @@ -2798,14 +2653,13 @@ func (s *TimerLayerGroupStore) CreateGroupSyncable(groupSyncable *model.GroupSyn resultVar0, resultVar1 := s.GroupStore.CreateGroupSyncable(groupSyncable) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("GroupStore.CreateGroupSyncable", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("GroupStore.CreateGroupSyncable", success, elapsed) } return resultVar0, resultVar1 } @@ -2815,14 +2669,13 @@ func (s *TimerLayerGroupStore) Delete(groupID string) (*model.Group, *model.AppE resultVar0, resultVar1 := s.GroupStore.Delete(groupID) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("GroupStore.Delete", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("GroupStore.Delete", success, elapsed) } return resultVar0, resultVar1 } @@ -2832,14 +2685,13 @@ func (s *TimerLayerGroupStore) DeleteGroupSyncable(groupID string, syncableID st resultVar0, resultVar1 := s.GroupStore.DeleteGroupSyncable(groupID, syncableID, syncableType) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("GroupStore.DeleteGroupSyncable", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("GroupStore.DeleteGroupSyncable", success, elapsed) } return resultVar0, resultVar1 } @@ -2849,14 +2701,13 @@ func (s *TimerLayerGroupStore) DeleteMember(groupID string, userID string) (*mod resultVar0, resultVar1 := s.GroupStore.DeleteMember(groupID, userID) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("GroupStore.DeleteMember", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("GroupStore.DeleteMember", success, elapsed) } return resultVar0, resultVar1 } @@ -2866,14 +2717,13 @@ func (s *TimerLayerGroupStore) Get(groupID string) (*model.Group, *model.AppErro resultVar0, resultVar1 := s.GroupStore.Get(groupID) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("GroupStore.Get", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("GroupStore.Get", success, elapsed) } return resultVar0, resultVar1 } @@ -2883,14 +2733,13 @@ func (s *TimerLayerGroupStore) GetAllBySource(groupSource model.GroupSource) ([] resultVar0, resultVar1 := s.GroupStore.GetAllBySource(groupSource) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("GroupStore.GetAllBySource", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("GroupStore.GetAllBySource", success, elapsed) } return resultVar0, resultVar1 } @@ -2900,14 +2749,13 @@ func (s *TimerLayerGroupStore) GetAllGroupSyncablesByGroupId(groupID string, syn resultVar0, resultVar1 := s.GroupStore.GetAllGroupSyncablesByGroupId(groupID, syncableType) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("GroupStore.GetAllGroupSyncablesByGroupId", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("GroupStore.GetAllGroupSyncablesByGroupId", success, elapsed) } return resultVar0, resultVar1 } @@ -2917,14 +2765,13 @@ func (s *TimerLayerGroupStore) GetByIDs(groupIDs []string) ([]*model.Group, *mod resultVar0, resultVar1 := s.GroupStore.GetByIDs(groupIDs) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("GroupStore.GetByIDs", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("GroupStore.GetByIDs", success, elapsed) } return resultVar0, resultVar1 } @@ -2934,14 +2781,13 @@ func (s *TimerLayerGroupStore) GetByRemoteID(remoteID string, groupSource model. resultVar0, resultVar1 := s.GroupStore.GetByRemoteID(remoteID, groupSource) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("GroupStore.GetByRemoteID", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("GroupStore.GetByRemoteID", success, elapsed) } return resultVar0, resultVar1 } @@ -2951,14 +2797,13 @@ func (s *TimerLayerGroupStore) GetGroupSyncable(groupID string, syncableID strin resultVar0, resultVar1 := s.GroupStore.GetGroupSyncable(groupID, syncableID, syncableType) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("GroupStore.GetGroupSyncable", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("GroupStore.GetGroupSyncable", success, elapsed) } return resultVar0, resultVar1 } @@ -2968,14 +2813,13 @@ func (s *TimerLayerGroupStore) GetGroups(page int, perPage int, opts model.Group resultVar0, resultVar1 := s.GroupStore.GetGroups(page, perPage, opts) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("GroupStore.GetGroups", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("GroupStore.GetGroups", success, elapsed) } return resultVar0, resultVar1 } @@ -2985,14 +2829,13 @@ func (s *TimerLayerGroupStore) GetGroupsByChannel(channelId string, opts model.G resultVar0, resultVar1 := s.GroupStore.GetGroupsByChannel(channelId, opts) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("GroupStore.GetGroupsByChannel", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("GroupStore.GetGroupsByChannel", success, elapsed) } return resultVar0, resultVar1 } @@ -3002,14 +2845,13 @@ func (s *TimerLayerGroupStore) GetGroupsByTeam(teamId string, opts model.GroupSe resultVar0, resultVar1 := s.GroupStore.GetGroupsByTeam(teamId, opts) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("GroupStore.GetGroupsByTeam", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("GroupStore.GetGroupsByTeam", success, elapsed) } return resultVar0, resultVar1 } @@ -3019,14 +2861,13 @@ func (s *TimerLayerGroupStore) GetMemberCount(groupID string) (int64, *model.App resultVar0, resultVar1 := s.GroupStore.GetMemberCount(groupID) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("GroupStore.GetMemberCount", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("GroupStore.GetMemberCount", success, elapsed) } return resultVar0, resultVar1 } @@ -3036,14 +2877,13 @@ func (s *TimerLayerGroupStore) GetMemberUsers(groupID string) ([]*model.User, *m resultVar0, resultVar1 := s.GroupStore.GetMemberUsers(groupID) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("GroupStore.GetMemberUsers", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("GroupStore.GetMemberUsers", success, elapsed) } return resultVar0, resultVar1 } @@ -3053,14 +2893,13 @@ func (s *TimerLayerGroupStore) GetMemberUsersPage(groupID string, page int, perP resultVar0, resultVar1 := s.GroupStore.GetMemberUsersPage(groupID, page, perPage) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("GroupStore.GetMemberUsersPage", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("GroupStore.GetMemberUsersPage", success, elapsed) } return resultVar0, resultVar1 } @@ -3070,14 +2909,13 @@ func (s *TimerLayerGroupStore) TeamMembersMinusGroupMembers(teamID string, group resultVar0, resultVar1 := s.GroupStore.TeamMembersMinusGroupMembers(teamID, groupIDs, page, perPage) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("GroupStore.TeamMembersMinusGroupMembers", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("GroupStore.TeamMembersMinusGroupMembers", success, elapsed) } return resultVar0, resultVar1 } @@ -3087,14 +2925,13 @@ func (s *TimerLayerGroupStore) TeamMembersToAdd(since int64) ([]*model.UserTeamI resultVar0, resultVar1 := s.GroupStore.TeamMembersToAdd(since) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("GroupStore.TeamMembersToAdd", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("GroupStore.TeamMembersToAdd", success, elapsed) } return resultVar0, resultVar1 } @@ -3104,14 +2941,13 @@ func (s *TimerLayerGroupStore) TeamMembersToRemove() ([]*model.TeamMember, *mode resultVar0, resultVar1 := s.GroupStore.TeamMembersToRemove() - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("GroupStore.TeamMembersToRemove", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("GroupStore.TeamMembersToRemove", success, elapsed) } return resultVar0, resultVar1 } @@ -3121,14 +2957,13 @@ func (s *TimerLayerGroupStore) Update(group *model.Group) (*model.Group, *model. resultVar0, resultVar1 := s.GroupStore.Update(group) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("GroupStore.Update", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("GroupStore.Update", success, elapsed) } return resultVar0, resultVar1 } @@ -3138,14 +2973,13 @@ func (s *TimerLayerGroupStore) UpdateGroupSyncable(groupSyncable *model.GroupSyn resultVar0, resultVar1 := s.GroupStore.UpdateGroupSyncable(groupSyncable) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("GroupStore.UpdateGroupSyncable", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("GroupStore.UpdateGroupSyncable", success, elapsed) } return resultVar0, resultVar1 } @@ -3155,14 +2989,13 @@ func (s *TimerLayerGroupStore) UpsertMember(groupID string, userID string) (*mod resultVar0, resultVar1 := s.GroupStore.UpsertMember(groupID, userID) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("GroupStore.UpsertMember", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("GroupStore.UpsertMember", success, elapsed) } return resultVar0, resultVar1 } @@ -3172,14 +3005,13 @@ func (s *TimerLayerJobStore) Delete(id string) (string, *model.AppError) { resultVar0, resultVar1 := s.JobStore.Delete(id) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("JobStore.Delete", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("JobStore.Delete", success, elapsed) } return resultVar0, resultVar1 } @@ -3189,14 +3021,13 @@ func (s *TimerLayerJobStore) Get(id string) (*model.Job, *model.AppError) { resultVar0, resultVar1 := s.JobStore.Get(id) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("JobStore.Get", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("JobStore.Get", success, elapsed) } return resultVar0, resultVar1 } @@ -3206,14 +3037,13 @@ func (s *TimerLayerJobStore) GetAllByStatus(status string) ([]*model.Job, *model resultVar0, resultVar1 := s.JobStore.GetAllByStatus(status) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("JobStore.GetAllByStatus", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("JobStore.GetAllByStatus", success, elapsed) } return resultVar0, resultVar1 } @@ -3223,14 +3053,13 @@ func (s *TimerLayerJobStore) GetAllByType(jobType string) ([]*model.Job, *model. resultVar0, resultVar1 := s.JobStore.GetAllByType(jobType) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("JobStore.GetAllByType", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("JobStore.GetAllByType", success, elapsed) } return resultVar0, resultVar1 } @@ -3240,14 +3069,13 @@ func (s *TimerLayerJobStore) GetAllByTypePage(jobType string, offset int, limit resultVar0, resultVar1 := s.JobStore.GetAllByTypePage(jobType, offset, limit) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("JobStore.GetAllByTypePage", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("JobStore.GetAllByTypePage", success, elapsed) } return resultVar0, resultVar1 } @@ -3257,14 +3085,13 @@ func (s *TimerLayerJobStore) GetAllPage(offset int, limit int) ([]*model.Job, *m resultVar0, resultVar1 := s.JobStore.GetAllPage(offset, limit) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("JobStore.GetAllPage", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("JobStore.GetAllPage", success, elapsed) } return resultVar0, resultVar1 } @@ -3274,14 +3101,13 @@ func (s *TimerLayerJobStore) GetCountByStatusAndType(status string, jobType stri resultVar0, resultVar1 := s.JobStore.GetCountByStatusAndType(status, jobType) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("JobStore.GetCountByStatusAndType", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("JobStore.GetCountByStatusAndType", success, elapsed) } return resultVar0, resultVar1 } @@ -3291,14 +3117,13 @@ func (s *TimerLayerJobStore) GetNewestJobByStatusAndType(status string, jobType resultVar0, resultVar1 := s.JobStore.GetNewestJobByStatusAndType(status, jobType) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("JobStore.GetNewestJobByStatusAndType", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("JobStore.GetNewestJobByStatusAndType", success, elapsed) } return resultVar0, resultVar1 } @@ -3308,14 +3133,13 @@ func (s *TimerLayerJobStore) Save(job *model.Job) (*model.Job, *model.AppError) resultVar0, resultVar1 := s.JobStore.Save(job) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("JobStore.Save", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("JobStore.Save", success, elapsed) } return resultVar0, resultVar1 } @@ -3325,14 +3149,13 @@ func (s *TimerLayerJobStore) UpdateOptimistically(job *model.Job, currentStatus resultVar0, resultVar1 := s.JobStore.UpdateOptimistically(job, currentStatus) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("JobStore.UpdateOptimistically", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("JobStore.UpdateOptimistically", success, elapsed) } return resultVar0, resultVar1 } @@ -3342,14 +3165,13 @@ func (s *TimerLayerJobStore) UpdateStatus(id string, status string) (*model.Job, resultVar0, resultVar1 := s.JobStore.UpdateStatus(id, status) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("JobStore.UpdateStatus", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("JobStore.UpdateStatus", success, elapsed) } return resultVar0, resultVar1 } @@ -3359,14 +3181,13 @@ func (s *TimerLayerJobStore) UpdateStatusOptimistically(id string, currentStatus resultVar0, resultVar1 := s.JobStore.UpdateStatusOptimistically(id, currentStatus, newStatus) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("JobStore.UpdateStatusOptimistically", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("JobStore.UpdateStatusOptimistically", success, elapsed) } return resultVar0, resultVar1 } @@ -3376,14 +3197,13 @@ func (s *TimerLayerLicenseStore) Get(id string) (*model.LicenseRecord, *model.Ap resultVar0, resultVar1 := s.LicenseStore.Get(id) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("LicenseStore.Get", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("LicenseStore.Get", success, elapsed) } return resultVar0, resultVar1 } @@ -3393,14 +3213,13 @@ func (s *TimerLayerLicenseStore) Save(license *model.LicenseRecord) (*model.Lice resultVar0, resultVar1 := s.LicenseStore.Save(license) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("LicenseStore.Save", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("LicenseStore.Save", success, elapsed) } return resultVar0, resultVar1 } @@ -3410,14 +3229,13 @@ func (s *TimerLayerLinkMetadataStore) Get(url string, timestamp int64) (*model.L resultVar0, resultVar1 := s.LinkMetadataStore.Get(url, timestamp) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("LinkMetadataStore.Get", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("LinkMetadataStore.Get", success, elapsed) } return resultVar0, resultVar1 } @@ -3427,14 +3245,13 @@ func (s *TimerLayerLinkMetadataStore) Save(linkMetadata *model.LinkMetadata) (*m resultVar0, resultVar1 := s.LinkMetadataStore.Save(linkMetadata) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("LinkMetadataStore.Save", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("LinkMetadataStore.Save", success, elapsed) } return resultVar0, resultVar1 } @@ -3444,14 +3261,13 @@ func (s *TimerLayerOAuthStore) DeleteApp(id string) *model.AppError { resultVar0 := s.OAuthStore.DeleteApp(id) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar0 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("OAuthStore.DeleteApp", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("OAuthStore.DeleteApp", success, elapsed) } return resultVar0 } @@ -3461,14 +3277,13 @@ func (s *TimerLayerOAuthStore) GetAccessData(token string) (*model.AccessData, * resultVar0, resultVar1 := s.OAuthStore.GetAccessData(token) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("OAuthStore.GetAccessData", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("OAuthStore.GetAccessData", success, elapsed) } return resultVar0, resultVar1 } @@ -3478,14 +3293,13 @@ func (s *TimerLayerOAuthStore) GetAccessDataByRefreshToken(token string) (*model resultVar0, resultVar1 := s.OAuthStore.GetAccessDataByRefreshToken(token) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("OAuthStore.GetAccessDataByRefreshToken", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("OAuthStore.GetAccessDataByRefreshToken", success, elapsed) } return resultVar0, resultVar1 } @@ -3495,14 +3309,13 @@ func (s *TimerLayerOAuthStore) GetAccessDataByUserForApp(userId string, clientId resultVar0, resultVar1 := s.OAuthStore.GetAccessDataByUserForApp(userId, clientId) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("OAuthStore.GetAccessDataByUserForApp", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("OAuthStore.GetAccessDataByUserForApp", success, elapsed) } return resultVar0, resultVar1 } @@ -3512,14 +3325,13 @@ func (s *TimerLayerOAuthStore) GetApp(id string) (*model.OAuthApp, *model.AppErr resultVar0, resultVar1 := s.OAuthStore.GetApp(id) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("OAuthStore.GetApp", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("OAuthStore.GetApp", success, elapsed) } return resultVar0, resultVar1 } @@ -3529,14 +3341,13 @@ func (s *TimerLayerOAuthStore) GetAppByUser(userId string, offset int, limit int resultVar0, resultVar1 := s.OAuthStore.GetAppByUser(userId, offset, limit) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("OAuthStore.GetAppByUser", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("OAuthStore.GetAppByUser", success, elapsed) } return resultVar0, resultVar1 } @@ -3546,14 +3357,13 @@ func (s *TimerLayerOAuthStore) GetApps(offset int, limit int) ([]*model.OAuthApp resultVar0, resultVar1 := s.OAuthStore.GetApps(offset, limit) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("OAuthStore.GetApps", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("OAuthStore.GetApps", success, elapsed) } return resultVar0, resultVar1 } @@ -3563,14 +3373,13 @@ func (s *TimerLayerOAuthStore) GetAuthData(code string) (*model.AuthData, *model resultVar0, resultVar1 := s.OAuthStore.GetAuthData(code) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("OAuthStore.GetAuthData", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("OAuthStore.GetAuthData", success, elapsed) } return resultVar0, resultVar1 } @@ -3580,14 +3389,13 @@ func (s *TimerLayerOAuthStore) GetAuthorizedApps(userId string, offset int, limi resultVar0, resultVar1 := s.OAuthStore.GetAuthorizedApps(userId, offset, limit) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("OAuthStore.GetAuthorizedApps", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("OAuthStore.GetAuthorizedApps", success, elapsed) } return resultVar0, resultVar1 } @@ -3597,14 +3405,13 @@ func (s *TimerLayerOAuthStore) GetPreviousAccessData(userId string, clientId str resultVar0, resultVar1 := s.OAuthStore.GetPreviousAccessData(userId, clientId) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("OAuthStore.GetPreviousAccessData", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("OAuthStore.GetPreviousAccessData", success, elapsed) } return resultVar0, resultVar1 } @@ -3614,14 +3421,13 @@ func (s *TimerLayerOAuthStore) PermanentDeleteAuthDataByUser(userId string) *mod resultVar0 := s.OAuthStore.PermanentDeleteAuthDataByUser(userId) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar0 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("OAuthStore.PermanentDeleteAuthDataByUser", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("OAuthStore.PermanentDeleteAuthDataByUser", success, elapsed) } return resultVar0 } @@ -3631,14 +3437,13 @@ func (s *TimerLayerOAuthStore) RemoveAccessData(token string) *model.AppError { resultVar0 := s.OAuthStore.RemoveAccessData(token) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar0 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("OAuthStore.RemoveAccessData", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("OAuthStore.RemoveAccessData", success, elapsed) } return resultVar0 } @@ -3648,14 +3453,13 @@ func (s *TimerLayerOAuthStore) RemoveAllAccessData() *model.AppError { resultVar0 := s.OAuthStore.RemoveAllAccessData() - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar0 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("OAuthStore.RemoveAllAccessData", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("OAuthStore.RemoveAllAccessData", success, elapsed) } return resultVar0 } @@ -3665,14 +3469,13 @@ func (s *TimerLayerOAuthStore) RemoveAuthData(code string) *model.AppError { resultVar0 := s.OAuthStore.RemoveAuthData(code) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar0 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("OAuthStore.RemoveAuthData", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("OAuthStore.RemoveAuthData", success, elapsed) } return resultVar0 } @@ -3682,14 +3485,13 @@ func (s *TimerLayerOAuthStore) SaveAccessData(accessData *model.AccessData) (*mo resultVar0, resultVar1 := s.OAuthStore.SaveAccessData(accessData) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("OAuthStore.SaveAccessData", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("OAuthStore.SaveAccessData", success, elapsed) } return resultVar0, resultVar1 } @@ -3699,14 +3501,13 @@ func (s *TimerLayerOAuthStore) SaveApp(app *model.OAuthApp) (*model.OAuthApp, *m resultVar0, resultVar1 := s.OAuthStore.SaveApp(app) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("OAuthStore.SaveApp", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("OAuthStore.SaveApp", success, elapsed) } return resultVar0, resultVar1 } @@ -3716,14 +3517,13 @@ func (s *TimerLayerOAuthStore) SaveAuthData(authData *model.AuthData) (*model.Au resultVar0, resultVar1 := s.OAuthStore.SaveAuthData(authData) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("OAuthStore.SaveAuthData", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("OAuthStore.SaveAuthData", success, elapsed) } return resultVar0, resultVar1 } @@ -3733,14 +3533,13 @@ func (s *TimerLayerOAuthStore) UpdateAccessData(accessData *model.AccessData) (* resultVar0, resultVar1 := s.OAuthStore.UpdateAccessData(accessData) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("OAuthStore.UpdateAccessData", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("OAuthStore.UpdateAccessData", success, elapsed) } return resultVar0, resultVar1 } @@ -3750,14 +3549,13 @@ func (s *TimerLayerOAuthStore) UpdateApp(app *model.OAuthApp) (*model.OAuthApp, resultVar0, resultVar1 := s.OAuthStore.UpdateApp(app) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("OAuthStore.UpdateApp", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("OAuthStore.UpdateApp", success, elapsed) } return resultVar0, resultVar1 } @@ -3767,14 +3565,13 @@ func (s *TimerLayerPluginStore) CompareAndDelete(keyVal *model.PluginKeyValue, o resultVar0, resultVar1 := s.PluginStore.CompareAndDelete(keyVal, oldValue) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("PluginStore.CompareAndDelete", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("PluginStore.CompareAndDelete", success, elapsed) } return resultVar0, resultVar1 } @@ -3784,14 +3581,13 @@ func (s *TimerLayerPluginStore) CompareAndSet(keyVal *model.PluginKeyValue, oldV resultVar0, resultVar1 := s.PluginStore.CompareAndSet(keyVal, oldValue) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("PluginStore.CompareAndSet", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("PluginStore.CompareAndSet", success, elapsed) } return resultVar0, resultVar1 } @@ -3801,14 +3597,13 @@ func (s *TimerLayerPluginStore) Delete(pluginId string, key string) *model.AppEr resultVar0 := s.PluginStore.Delete(pluginId, key) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar0 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("PluginStore.Delete", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("PluginStore.Delete", success, elapsed) } return resultVar0 } @@ -3818,14 +3613,13 @@ func (s *TimerLayerPluginStore) DeleteAllExpired() *model.AppError { resultVar0 := s.PluginStore.DeleteAllExpired() - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar0 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("PluginStore.DeleteAllExpired", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("PluginStore.DeleteAllExpired", success, elapsed) } return resultVar0 } @@ -3835,14 +3629,13 @@ func (s *TimerLayerPluginStore) DeleteAllForPlugin(PluginId string) *model.AppEr resultVar0 := s.PluginStore.DeleteAllForPlugin(PluginId) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar0 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("PluginStore.DeleteAllForPlugin", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("PluginStore.DeleteAllForPlugin", success, elapsed) } return resultVar0 } @@ -3852,14 +3645,13 @@ func (s *TimerLayerPluginStore) Get(pluginId string, key string) (*model.PluginK resultVar0, resultVar1 := s.PluginStore.Get(pluginId, key) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("PluginStore.Get", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("PluginStore.Get", success, elapsed) } return resultVar0, resultVar1 } @@ -3869,14 +3661,13 @@ func (s *TimerLayerPluginStore) List(pluginId string, page int, perPage int) ([] resultVar0, resultVar1 := s.PluginStore.List(pluginId, page, perPage) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("PluginStore.List", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("PluginStore.List", success, elapsed) } return resultVar0, resultVar1 } @@ -3886,14 +3677,13 @@ func (s *TimerLayerPluginStore) SaveOrUpdate(keyVal *model.PluginKeyValue) (*mod resultVar0, resultVar1 := s.PluginStore.SaveOrUpdate(keyVal) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("PluginStore.SaveOrUpdate", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("PluginStore.SaveOrUpdate", success, elapsed) } return resultVar0, resultVar1 } @@ -3903,14 +3693,13 @@ func (s *TimerLayerPostStore) AnalyticsPostCount(teamId string, mustHaveFile boo resultVar0, resultVar1 := s.PostStore.AnalyticsPostCount(teamId, mustHaveFile, mustHaveHashtag) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("PostStore.AnalyticsPostCount", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("PostStore.AnalyticsPostCount", success, elapsed) } return resultVar0, resultVar1 } @@ -3920,14 +3709,13 @@ func (s *TimerLayerPostStore) AnalyticsPostCountsByDay(options *model.AnalyticsP resultVar0, resultVar1 := s.PostStore.AnalyticsPostCountsByDay(options) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("PostStore.AnalyticsPostCountsByDay", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("PostStore.AnalyticsPostCountsByDay", success, elapsed) } return resultVar0, resultVar1 } @@ -3937,14 +3725,13 @@ func (s *TimerLayerPostStore) AnalyticsUserCountsWithPostsByDay(teamId string) ( resultVar0, resultVar1 := s.PostStore.AnalyticsUserCountsWithPostsByDay(teamId) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("PostStore.AnalyticsUserCountsWithPostsByDay", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("PostStore.AnalyticsUserCountsWithPostsByDay", success, elapsed) } return resultVar0, resultVar1 } @@ -3954,14 +3741,13 @@ func (s *TimerLayerPostStore) ClearCaches() { s.PostStore.ClearCaches() - t := timemodule.Now() - elapsed := t.Sub(start) + 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, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("PostStore.ClearCaches", success, elapsed) } return } @@ -3971,14 +3757,13 @@ func (s *TimerLayerPostStore) Delete(postId string, time int64, deleteByID strin resultVar0 := s.PostStore.Delete(postId, time, deleteByID) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar0 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("PostStore.Delete", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("PostStore.Delete", success, elapsed) } return resultVar0 } @@ -3988,14 +3773,13 @@ func (s *TimerLayerPostStore) Get(id string, skipFetchThreads bool) (*model.Post resultVar0, resultVar1 := s.PostStore.Get(id, skipFetchThreads) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("PostStore.Get", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("PostStore.Get", success, elapsed) } return resultVar0, resultVar1 } @@ -4005,14 +3789,13 @@ func (s *TimerLayerPostStore) GetDirectPostParentsForExportAfter(limit int, afte resultVar0, resultVar1 := s.PostStore.GetDirectPostParentsForExportAfter(limit, afterId) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("PostStore.GetDirectPostParentsForExportAfter", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("PostStore.GetDirectPostParentsForExportAfter", success, elapsed) } return resultVar0, resultVar1 } @@ -4022,14 +3805,13 @@ func (s *TimerLayerPostStore) GetEtag(channelId string, allowFromCache bool) str resultVar0 := s.PostStore.GetEtag(channelId, allowFromCache) - t := timemodule.Now() - elapsed := t.Sub(start) + 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, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("PostStore.GetEtag", success, elapsed) } return resultVar0 } @@ -4039,14 +3821,13 @@ func (s *TimerLayerPostStore) GetFlaggedPosts(userId string, offset int, limit i resultVar0, resultVar1 := s.PostStore.GetFlaggedPosts(userId, offset, limit) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("PostStore.GetFlaggedPosts", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("PostStore.GetFlaggedPosts", success, elapsed) } return resultVar0, resultVar1 } @@ -4056,14 +3837,13 @@ func (s *TimerLayerPostStore) GetFlaggedPostsForChannel(userId string, channelId resultVar0, resultVar1 := s.PostStore.GetFlaggedPostsForChannel(userId, channelId, offset, limit) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("PostStore.GetFlaggedPostsForChannel", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("PostStore.GetFlaggedPostsForChannel", success, elapsed) } return resultVar0, resultVar1 } @@ -4073,14 +3853,13 @@ func (s *TimerLayerPostStore) GetFlaggedPostsForTeam(userId string, teamId strin resultVar0, resultVar1 := s.PostStore.GetFlaggedPostsForTeam(userId, teamId, offset, limit) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("PostStore.GetFlaggedPostsForTeam", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("PostStore.GetFlaggedPostsForTeam", success, elapsed) } return resultVar0, resultVar1 } @@ -4090,14 +3869,13 @@ func (s *TimerLayerPostStore) GetMaxPostSize() int { resultVar0 := s.PostStore.GetMaxPostSize() - t := timemodule.Now() - elapsed := t.Sub(start) + 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, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("PostStore.GetMaxPostSize", success, elapsed) } return resultVar0 } @@ -4107,14 +3885,13 @@ func (s *TimerLayerPostStore) GetOldest() (*model.Post, *model.AppError) { resultVar0, resultVar1 := s.PostStore.GetOldest() - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("PostStore.GetOldest", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("PostStore.GetOldest", success, elapsed) } return resultVar0, resultVar1 } @@ -4124,14 +3901,13 @@ func (s *TimerLayerPostStore) GetParentsForExportAfter(limit int, afterId string resultVar0, resultVar1 := s.PostStore.GetParentsForExportAfter(limit, afterId) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("PostStore.GetParentsForExportAfter", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("PostStore.GetParentsForExportAfter", success, elapsed) } return resultVar0, resultVar1 } @@ -4141,14 +3917,13 @@ func (s *TimerLayerPostStore) GetPostAfterTime(channelId string, time int64) (*m resultVar0, resultVar1 := s.PostStore.GetPostAfterTime(channelId, time) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("PostStore.GetPostAfterTime", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("PostStore.GetPostAfterTime", success, elapsed) } return resultVar0, resultVar1 } @@ -4158,14 +3933,13 @@ func (s *TimerLayerPostStore) GetPostIdAfterTime(channelId string, time int64) ( resultVar0, resultVar1 := s.PostStore.GetPostIdAfterTime(channelId, time) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("PostStore.GetPostIdAfterTime", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("PostStore.GetPostIdAfterTime", success, elapsed) } return resultVar0, resultVar1 } @@ -4175,14 +3949,13 @@ func (s *TimerLayerPostStore) GetPostIdBeforeTime(channelId string, time int64) resultVar0, resultVar1 := s.PostStore.GetPostIdBeforeTime(channelId, time) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("PostStore.GetPostIdBeforeTime", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("PostStore.GetPostIdBeforeTime", success, elapsed) } return resultVar0, resultVar1 } @@ -4192,14 +3965,13 @@ func (s *TimerLayerPostStore) GetPosts(options model.GetPostsOptions, allowFromC resultVar0, resultVar1 := s.PostStore.GetPosts(options, allowFromCache) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("PostStore.GetPosts", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("PostStore.GetPosts", success, elapsed) } return resultVar0, resultVar1 } @@ -4209,14 +3981,13 @@ func (s *TimerLayerPostStore) GetPostsAfter(options model.GetPostsOptions) (*mod resultVar0, resultVar1 := s.PostStore.GetPostsAfter(options) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("PostStore.GetPostsAfter", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("PostStore.GetPostsAfter", success, elapsed) } return resultVar0, resultVar1 } @@ -4226,14 +3997,13 @@ func (s *TimerLayerPostStore) GetPostsBatchForIndexing(startTime int64, endTime resultVar0, resultVar1 := s.PostStore.GetPostsBatchForIndexing(startTime, endTime, limit) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("PostStore.GetPostsBatchForIndexing", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("PostStore.GetPostsBatchForIndexing", success, elapsed) } return resultVar0, resultVar1 } @@ -4243,14 +4013,13 @@ func (s *TimerLayerPostStore) GetPostsBefore(options model.GetPostsOptions) (*mo resultVar0, resultVar1 := s.PostStore.GetPostsBefore(options) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("PostStore.GetPostsBefore", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("PostStore.GetPostsBefore", success, elapsed) } return resultVar0, resultVar1 } @@ -4260,14 +4029,13 @@ func (s *TimerLayerPostStore) GetPostsByIds(postIds []string) ([]*model.Post, *m resultVar0, resultVar1 := s.PostStore.GetPostsByIds(postIds) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("PostStore.GetPostsByIds", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("PostStore.GetPostsByIds", success, elapsed) } return resultVar0, resultVar1 } @@ -4277,14 +4045,13 @@ func (s *TimerLayerPostStore) GetPostsCreatedAt(channelId string, time int64) ([ resultVar0, resultVar1 := s.PostStore.GetPostsCreatedAt(channelId, time) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("PostStore.GetPostsCreatedAt", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("PostStore.GetPostsCreatedAt", success, elapsed) } return resultVar0, resultVar1 } @@ -4294,14 +4061,13 @@ func (s *TimerLayerPostStore) GetPostsSince(options model.GetPostsSinceOptions, resultVar0, resultVar1 := s.PostStore.GetPostsSince(options, allowFromCache) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("PostStore.GetPostsSince", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("PostStore.GetPostsSince", success, elapsed) } return resultVar0, resultVar1 } @@ -4311,14 +4077,13 @@ func (s *TimerLayerPostStore) GetRepliesForExport(parentId string) ([]*model.Rep resultVar0, resultVar1 := s.PostStore.GetRepliesForExport(parentId) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("PostStore.GetRepliesForExport", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("PostStore.GetRepliesForExport", success, elapsed) } return resultVar0, resultVar1 } @@ -4328,14 +4093,13 @@ func (s *TimerLayerPostStore) GetSingle(id string) (*model.Post, *model.AppError resultVar0, resultVar1 := s.PostStore.GetSingle(id) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("PostStore.GetSingle", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("PostStore.GetSingle", success, elapsed) } return resultVar0, resultVar1 } @@ -4345,14 +4109,13 @@ func (s *TimerLayerPostStore) InvalidateLastPostTimeCache(channelId string) { s.PostStore.InvalidateLastPostTimeCache(channelId) - t := timemodule.Now() - elapsed := t.Sub(start) + 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, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("PostStore.InvalidateLastPostTimeCache", success, elapsed) } return } @@ -4362,14 +4125,13 @@ func (s *TimerLayerPostStore) Overwrite(post *model.Post) (*model.Post, *model.A resultVar0, resultVar1 := s.PostStore.Overwrite(post) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("PostStore.Overwrite", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("PostStore.Overwrite", success, elapsed) } return resultVar0, resultVar1 } @@ -4379,14 +4141,13 @@ func (s *TimerLayerPostStore) PermanentDeleteBatch(endTime int64, limit int64) ( resultVar0, resultVar1 := s.PostStore.PermanentDeleteBatch(endTime, limit) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("PostStore.PermanentDeleteBatch", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("PostStore.PermanentDeleteBatch", success, elapsed) } return resultVar0, resultVar1 } @@ -4396,14 +4157,13 @@ func (s *TimerLayerPostStore) PermanentDeleteByChannel(channelId string) *model. resultVar0 := s.PostStore.PermanentDeleteByChannel(channelId) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar0 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("PostStore.PermanentDeleteByChannel", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("PostStore.PermanentDeleteByChannel", success, elapsed) } return resultVar0 } @@ -4413,14 +4173,13 @@ func (s *TimerLayerPostStore) PermanentDeleteByUser(userId string) *model.AppErr resultVar0 := s.PostStore.PermanentDeleteByUser(userId) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar0 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("PostStore.PermanentDeleteByUser", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("PostStore.PermanentDeleteByUser", success, elapsed) } return resultVar0 } @@ -4430,14 +4189,13 @@ func (s *TimerLayerPostStore) Save(post *model.Post) (*model.Post, *model.AppErr resultVar0, resultVar1 := s.PostStore.Save(post) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("PostStore.Save", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("PostStore.Save", success, elapsed) } return resultVar0, resultVar1 } @@ -4447,14 +4205,13 @@ func (s *TimerLayerPostStore) Search(teamId string, userId string, params *model resultVar0, resultVar1 := s.PostStore.Search(teamId, userId, params) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("PostStore.Search", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("PostStore.Search", success, elapsed) } return resultVar0, resultVar1 } @@ -4464,14 +4221,13 @@ func (s *TimerLayerPostStore) Update(newPost *model.Post, oldPost *model.Post) ( resultVar0, resultVar1 := s.PostStore.Update(newPost, oldPost) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("PostStore.Update", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("PostStore.Update", success, elapsed) } return resultVar0, resultVar1 } @@ -4481,14 +4237,13 @@ func (s *TimerLayerPreferenceStore) CleanupFlagsBatch(limit int64) (int64, *mode resultVar0, resultVar1 := s.PreferenceStore.CleanupFlagsBatch(limit) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("PreferenceStore.CleanupFlagsBatch", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("PreferenceStore.CleanupFlagsBatch", success, elapsed) } return resultVar0, resultVar1 } @@ -4498,14 +4253,13 @@ func (s *TimerLayerPreferenceStore) Delete(userId string, category string, name resultVar0 := s.PreferenceStore.Delete(userId, category, name) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar0 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("PreferenceStore.Delete", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("PreferenceStore.Delete", success, elapsed) } return resultVar0 } @@ -4515,14 +4269,13 @@ func (s *TimerLayerPreferenceStore) DeleteCategory(userId string, category strin resultVar0 := s.PreferenceStore.DeleteCategory(userId, category) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar0 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("PreferenceStore.DeleteCategory", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("PreferenceStore.DeleteCategory", success, elapsed) } return resultVar0 } @@ -4532,14 +4285,13 @@ func (s *TimerLayerPreferenceStore) DeleteCategoryAndName(category string, name resultVar0 := s.PreferenceStore.DeleteCategoryAndName(category, name) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar0 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("PreferenceStore.DeleteCategoryAndName", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("PreferenceStore.DeleteCategoryAndName", success, elapsed) } return resultVar0 } @@ -4549,14 +4301,13 @@ func (s *TimerLayerPreferenceStore) Get(userId string, category string, name str resultVar0, resultVar1 := s.PreferenceStore.Get(userId, category, name) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("PreferenceStore.Get", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("PreferenceStore.Get", success, elapsed) } return resultVar0, resultVar1 } @@ -4566,14 +4317,13 @@ func (s *TimerLayerPreferenceStore) GetAll(userId string) (model.Preferences, *m resultVar0, resultVar1 := s.PreferenceStore.GetAll(userId) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("PreferenceStore.GetAll", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("PreferenceStore.GetAll", success, elapsed) } return resultVar0, resultVar1 } @@ -4583,14 +4333,13 @@ func (s *TimerLayerPreferenceStore) GetCategory(userId string, category string) resultVar0, resultVar1 := s.PreferenceStore.GetCategory(userId, category) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("PreferenceStore.GetCategory", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("PreferenceStore.GetCategory", success, elapsed) } return resultVar0, resultVar1 } @@ -4600,14 +4349,13 @@ func (s *TimerLayerPreferenceStore) PermanentDeleteByUser(userId string) *model. resultVar0 := s.PreferenceStore.PermanentDeleteByUser(userId) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar0 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("PreferenceStore.PermanentDeleteByUser", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("PreferenceStore.PermanentDeleteByUser", success, elapsed) } return resultVar0 } @@ -4617,14 +4365,13 @@ func (s *TimerLayerPreferenceStore) Save(preferences *model.Preferences) *model. resultVar0 := s.PreferenceStore.Save(preferences) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar0 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("PreferenceStore.Save", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("PreferenceStore.Save", success, elapsed) } return resultVar0 } @@ -4634,14 +4381,13 @@ func (s *TimerLayerReactionStore) BulkGetForPosts(postIds []string) ([]*model.Re resultVar0, resultVar1 := s.ReactionStore.BulkGetForPosts(postIds) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("ReactionStore.BulkGetForPosts", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("ReactionStore.BulkGetForPosts", success, elapsed) } return resultVar0, resultVar1 } @@ -4651,14 +4397,13 @@ func (s *TimerLayerReactionStore) Delete(reaction *model.Reaction) (*model.React resultVar0, resultVar1 := s.ReactionStore.Delete(reaction) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("ReactionStore.Delete", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("ReactionStore.Delete", success, elapsed) } return resultVar0, resultVar1 } @@ -4668,14 +4413,13 @@ func (s *TimerLayerReactionStore) DeleteAllWithEmojiName(emojiName string) *mode resultVar0 := s.ReactionStore.DeleteAllWithEmojiName(emojiName) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar0 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("ReactionStore.DeleteAllWithEmojiName", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("ReactionStore.DeleteAllWithEmojiName", success, elapsed) } return resultVar0 } @@ -4685,14 +4429,13 @@ func (s *TimerLayerReactionStore) GetForPost(postId string, allowFromCache bool) resultVar0, resultVar1 := s.ReactionStore.GetForPost(postId, allowFromCache) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("ReactionStore.GetForPost", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("ReactionStore.GetForPost", success, elapsed) } return resultVar0, resultVar1 } @@ -4702,14 +4445,13 @@ func (s *TimerLayerReactionStore) PermanentDeleteBatch(endTime int64, limit int6 resultVar0, resultVar1 := s.ReactionStore.PermanentDeleteBatch(endTime, limit) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("ReactionStore.PermanentDeleteBatch", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("ReactionStore.PermanentDeleteBatch", success, elapsed) } return resultVar0, resultVar1 } @@ -4719,14 +4461,13 @@ func (s *TimerLayerReactionStore) Save(reaction *model.Reaction) (*model.Reactio resultVar0, resultVar1 := s.ReactionStore.Save(reaction) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("ReactionStore.Save", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("ReactionStore.Save", success, elapsed) } return resultVar0, resultVar1 } @@ -4736,14 +4477,13 @@ func (s *TimerLayerRoleStore) Delete(roldId string) (*model.Role, *model.AppErro resultVar0, resultVar1 := s.RoleStore.Delete(roldId) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("RoleStore.Delete", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("RoleStore.Delete", success, elapsed) } return resultVar0, resultVar1 } @@ -4753,14 +4493,13 @@ func (s *TimerLayerRoleStore) Get(roleId string) (*model.Role, *model.AppError) resultVar0, resultVar1 := s.RoleStore.Get(roleId) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("RoleStore.Get", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("RoleStore.Get", success, elapsed) } return resultVar0, resultVar1 } @@ -4770,14 +4509,13 @@ func (s *TimerLayerRoleStore) GetAll() ([]*model.Role, *model.AppError) { resultVar0, resultVar1 := s.RoleStore.GetAll() - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("RoleStore.GetAll", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("RoleStore.GetAll", success, elapsed) } return resultVar0, resultVar1 } @@ -4787,14 +4525,13 @@ func (s *TimerLayerRoleStore) GetByName(name string) (*model.Role, *model.AppErr resultVar0, resultVar1 := s.RoleStore.GetByName(name) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("RoleStore.GetByName", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("RoleStore.GetByName", success, elapsed) } return resultVar0, resultVar1 } @@ -4804,14 +4541,13 @@ func (s *TimerLayerRoleStore) GetByNames(names []string) ([]*model.Role, *model. resultVar0, resultVar1 := s.RoleStore.GetByNames(names) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("RoleStore.GetByNames", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("RoleStore.GetByNames", success, elapsed) } return resultVar0, resultVar1 } @@ -4821,14 +4557,13 @@ func (s *TimerLayerRoleStore) PermanentDeleteAll() *model.AppError { resultVar0 := s.RoleStore.PermanentDeleteAll() - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar0 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("RoleStore.PermanentDeleteAll", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("RoleStore.PermanentDeleteAll", success, elapsed) } return resultVar0 } @@ -4838,14 +4573,13 @@ func (s *TimerLayerRoleStore) Save(role *model.Role) (*model.Role, *model.AppErr resultVar0, resultVar1 := s.RoleStore.Save(role) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("RoleStore.Save", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("RoleStore.Save", success, elapsed) } return resultVar0, resultVar1 } @@ -4855,14 +4589,13 @@ func (s *TimerLayerSchemeStore) Delete(schemeId string) (*model.Scheme, *model.A resultVar0, resultVar1 := s.SchemeStore.Delete(schemeId) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("SchemeStore.Delete", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("SchemeStore.Delete", success, elapsed) } return resultVar0, resultVar1 } @@ -4872,14 +4605,13 @@ func (s *TimerLayerSchemeStore) Get(schemeId string) (*model.Scheme, *model.AppE resultVar0, resultVar1 := s.SchemeStore.Get(schemeId) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("SchemeStore.Get", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("SchemeStore.Get", success, elapsed) } return resultVar0, resultVar1 } @@ -4889,14 +4621,13 @@ func (s *TimerLayerSchemeStore) GetAllPage(scope string, offset int, limit int) resultVar0, resultVar1 := s.SchemeStore.GetAllPage(scope, offset, limit) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("SchemeStore.GetAllPage", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("SchemeStore.GetAllPage", success, elapsed) } return resultVar0, resultVar1 } @@ -4906,14 +4637,13 @@ func (s *TimerLayerSchemeStore) GetByName(schemeName string) (*model.Scheme, *mo resultVar0, resultVar1 := s.SchemeStore.GetByName(schemeName) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("SchemeStore.GetByName", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("SchemeStore.GetByName", success, elapsed) } return resultVar0, resultVar1 } @@ -4923,14 +4653,13 @@ func (s *TimerLayerSchemeStore) PermanentDeleteAll() *model.AppError { resultVar0 := s.SchemeStore.PermanentDeleteAll() - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar0 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("SchemeStore.PermanentDeleteAll", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("SchemeStore.PermanentDeleteAll", success, elapsed) } return resultVar0 } @@ -4940,14 +4669,13 @@ func (s *TimerLayerSchemeStore) Save(scheme *model.Scheme) (*model.Scheme, *mode resultVar0, resultVar1 := s.SchemeStore.Save(scheme) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("SchemeStore.Save", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("SchemeStore.Save", success, elapsed) } return resultVar0, resultVar1 } @@ -4957,14 +4685,13 @@ func (s *TimerLayerSessionStore) AnalyticsSessionCount() (int64, *model.AppError resultVar0, resultVar1 := s.SessionStore.AnalyticsSessionCount() - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("SessionStore.AnalyticsSessionCount", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("SessionStore.AnalyticsSessionCount", success, elapsed) } return resultVar0, resultVar1 } @@ -4974,14 +4701,13 @@ func (s *TimerLayerSessionStore) Cleanup(expiryTime int64, batchSize int64) { s.SessionStore.Cleanup(expiryTime, batchSize) - t := timemodule.Now() - elapsed := t.Sub(start) + 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, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("SessionStore.Cleanup", success, elapsed) } return } @@ -4991,14 +4717,13 @@ func (s *TimerLayerSessionStore) Get(sessionIdOrToken string) (*model.Session, * resultVar0, resultVar1 := s.SessionStore.Get(sessionIdOrToken) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("SessionStore.Get", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("SessionStore.Get", success, elapsed) } return resultVar0, resultVar1 } @@ -5008,14 +4733,13 @@ func (s *TimerLayerSessionStore) GetSessions(userId string) ([]*model.Session, * resultVar0, resultVar1 := s.SessionStore.GetSessions(userId) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("SessionStore.GetSessions", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("SessionStore.GetSessions", success, elapsed) } return resultVar0, resultVar1 } @@ -5025,14 +4749,13 @@ func (s *TimerLayerSessionStore) GetSessionsWithActiveDeviceIds(userId string) ( resultVar0, resultVar1 := s.SessionStore.GetSessionsWithActiveDeviceIds(userId) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("SessionStore.GetSessionsWithActiveDeviceIds", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("SessionStore.GetSessionsWithActiveDeviceIds", success, elapsed) } return resultVar0, resultVar1 } @@ -5042,14 +4765,13 @@ func (s *TimerLayerSessionStore) PermanentDeleteSessionsByUser(teamId string) *m resultVar0 := s.SessionStore.PermanentDeleteSessionsByUser(teamId) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar0 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("SessionStore.PermanentDeleteSessionsByUser", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("SessionStore.PermanentDeleteSessionsByUser", success, elapsed) } return resultVar0 } @@ -5059,14 +4781,13 @@ func (s *TimerLayerSessionStore) Remove(sessionIdOrToken string) *model.AppError resultVar0 := s.SessionStore.Remove(sessionIdOrToken) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar0 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("SessionStore.Remove", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("SessionStore.Remove", success, elapsed) } return resultVar0 } @@ -5076,14 +4797,13 @@ func (s *TimerLayerSessionStore) RemoveAllSessions() *model.AppError { resultVar0 := s.SessionStore.RemoveAllSessions() - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar0 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("SessionStore.RemoveAllSessions", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("SessionStore.RemoveAllSessions", success, elapsed) } return resultVar0 } @@ -5093,14 +4813,13 @@ func (s *TimerLayerSessionStore) Save(session *model.Session) (*model.Session, * resultVar0, resultVar1 := s.SessionStore.Save(session) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("SessionStore.Save", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("SessionStore.Save", success, elapsed) } return resultVar0, resultVar1 } @@ -5110,14 +4829,13 @@ func (s *TimerLayerSessionStore) UpdateDeviceId(id string, deviceId string, expi resultVar0, resultVar1 := s.SessionStore.UpdateDeviceId(id, deviceId, expiresAt) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("SessionStore.UpdateDeviceId", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("SessionStore.UpdateDeviceId", success, elapsed) } return resultVar0, resultVar1 } @@ -5127,14 +4845,13 @@ func (s *TimerLayerSessionStore) UpdateLastActivityAt(sessionId string, time int resultVar0 := s.SessionStore.UpdateLastActivityAt(sessionId, time) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar0 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("SessionStore.UpdateLastActivityAt", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("SessionStore.UpdateLastActivityAt", success, elapsed) } return resultVar0 } @@ -5144,14 +4861,13 @@ func (s *TimerLayerSessionStore) UpdateProps(session *model.Session) *model.AppE resultVar0 := s.SessionStore.UpdateProps(session) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar0 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("SessionStore.UpdateProps", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("SessionStore.UpdateProps", success, elapsed) } return resultVar0 } @@ -5161,14 +4877,13 @@ func (s *TimerLayerSessionStore) UpdateRoles(userId string, roles string) (strin resultVar0, resultVar1 := s.SessionStore.UpdateRoles(userId, roles) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("SessionStore.UpdateRoles", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("SessionStore.UpdateRoles", success, elapsed) } return resultVar0, resultVar1 } @@ -5178,14 +4893,13 @@ func (s *TimerLayerStatusStore) Get(userId string) (*model.Status, *model.AppErr resultVar0, resultVar1 := s.StatusStore.Get(userId) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("StatusStore.Get", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("StatusStore.Get", success, elapsed) } return resultVar0, resultVar1 } @@ -5195,14 +4909,13 @@ func (s *TimerLayerStatusStore) GetByIds(userIds []string) ([]*model.Status, *mo resultVar0, resultVar1 := s.StatusStore.GetByIds(userIds) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("StatusStore.GetByIds", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("StatusStore.GetByIds", success, elapsed) } return resultVar0, resultVar1 } @@ -5212,14 +4925,13 @@ func (s *TimerLayerStatusStore) GetTotalActiveUsersCount() (int64, *model.AppErr resultVar0, resultVar1 := s.StatusStore.GetTotalActiveUsersCount() - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("StatusStore.GetTotalActiveUsersCount", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("StatusStore.GetTotalActiveUsersCount", success, elapsed) } return resultVar0, resultVar1 } @@ -5229,14 +4941,13 @@ func (s *TimerLayerStatusStore) ResetAll() *model.AppError { resultVar0 := s.StatusStore.ResetAll() - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar0 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("StatusStore.ResetAll", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("StatusStore.ResetAll", success, elapsed) } return resultVar0 } @@ -5246,14 +4957,13 @@ func (s *TimerLayerStatusStore) SaveOrUpdate(status *model.Status) *model.AppErr resultVar0 := s.StatusStore.SaveOrUpdate(status) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar0 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("StatusStore.SaveOrUpdate", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("StatusStore.SaveOrUpdate", success, elapsed) } return resultVar0 } @@ -5263,14 +4973,13 @@ func (s *TimerLayerStatusStore) UpdateLastActivityAt(userId string, lastActivity resultVar0 := s.StatusStore.UpdateLastActivityAt(userId, lastActivityAt) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar0 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("StatusStore.UpdateLastActivityAt", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("StatusStore.UpdateLastActivityAt", success, elapsed) } return resultVar0 } @@ -5280,14 +4989,13 @@ func (s *TimerLayerSystemStore) Get() (model.StringMap, *model.AppError) { resultVar0, resultVar1 := s.SystemStore.Get() - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("SystemStore.Get", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("SystemStore.Get", success, elapsed) } return resultVar0, resultVar1 } @@ -5297,14 +5005,13 @@ func (s *TimerLayerSystemStore) GetByName(name string) (*model.System, *model.Ap resultVar0, resultVar1 := s.SystemStore.GetByName(name) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("SystemStore.GetByName", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("SystemStore.GetByName", success, elapsed) } return resultVar0, resultVar1 } @@ -5314,14 +5021,13 @@ func (s *TimerLayerSystemStore) PermanentDeleteByName(name string) (*model.Syste resultVar0, resultVar1 := s.SystemStore.PermanentDeleteByName(name) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("SystemStore.PermanentDeleteByName", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("SystemStore.PermanentDeleteByName", success, elapsed) } return resultVar0, resultVar1 } @@ -5331,14 +5037,13 @@ func (s *TimerLayerSystemStore) Save(system *model.System) *model.AppError { resultVar0 := s.SystemStore.Save(system) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar0 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("SystemStore.Save", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("SystemStore.Save", success, elapsed) } return resultVar0 } @@ -5348,14 +5053,13 @@ func (s *TimerLayerSystemStore) SaveOrUpdate(system *model.System) *model.AppErr resultVar0 := s.SystemStore.SaveOrUpdate(system) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar0 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("SystemStore.SaveOrUpdate", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("SystemStore.SaveOrUpdate", success, elapsed) } return resultVar0 } @@ -5365,14 +5069,13 @@ func (s *TimerLayerSystemStore) Update(system *model.System) *model.AppError { resultVar0 := s.SystemStore.Update(system) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar0 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("SystemStore.Update", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("SystemStore.Update", success, elapsed) } return resultVar0 } @@ -5382,14 +5085,13 @@ func (s *TimerLayerTeamStore) AnalyticsGetTeamCountForScheme(schemeId string) (i resultVar0, resultVar1 := s.TeamStore.AnalyticsGetTeamCountForScheme(schemeId) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("TeamStore.AnalyticsGetTeamCountForScheme", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("TeamStore.AnalyticsGetTeamCountForScheme", success, elapsed) } return resultVar0, resultVar1 } @@ -5399,14 +5101,13 @@ func (s *TimerLayerTeamStore) AnalyticsPrivateTeamCount() (int64, *model.AppErro resultVar0, resultVar1 := s.TeamStore.AnalyticsPrivateTeamCount() - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("TeamStore.AnalyticsPrivateTeamCount", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("TeamStore.AnalyticsPrivateTeamCount", success, elapsed) } return resultVar0, resultVar1 } @@ -5416,14 +5117,13 @@ func (s *TimerLayerTeamStore) AnalyticsPublicTeamCount() (int64, *model.AppError resultVar0, resultVar1 := s.TeamStore.AnalyticsPublicTeamCount() - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("TeamStore.AnalyticsPublicTeamCount", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("TeamStore.AnalyticsPublicTeamCount", success, elapsed) } return resultVar0, resultVar1 } @@ -5433,14 +5133,13 @@ func (s *TimerLayerTeamStore) AnalyticsTeamCount() (int64, *model.AppError) { resultVar0, resultVar1 := s.TeamStore.AnalyticsTeamCount() - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("TeamStore.AnalyticsTeamCount", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("TeamStore.AnalyticsTeamCount", success, elapsed) } return resultVar0, resultVar1 } @@ -5450,14 +5149,13 @@ func (s *TimerLayerTeamStore) ClearAllCustomRoleAssignments() *model.AppError { resultVar0 := s.TeamStore.ClearAllCustomRoleAssignments() - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar0 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("TeamStore.ClearAllCustomRoleAssignments", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("TeamStore.ClearAllCustomRoleAssignments", success, elapsed) } return resultVar0 } @@ -5467,14 +5165,13 @@ func (s *TimerLayerTeamStore) ClearCaches() { s.TeamStore.ClearCaches() - t := timemodule.Now() - elapsed := t.Sub(start) + 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, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("TeamStore.ClearCaches", success, elapsed) } return } @@ -5484,14 +5181,13 @@ func (s *TimerLayerTeamStore) Get(id string) (*model.Team, *model.AppError) { resultVar0, resultVar1 := s.TeamStore.Get(id) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("TeamStore.Get", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("TeamStore.Get", success, elapsed) } return resultVar0, resultVar1 } @@ -5501,14 +5197,13 @@ func (s *TimerLayerTeamStore) GetActiveMemberCount(teamId string, restrictions * resultVar0, resultVar1 := s.TeamStore.GetActiveMemberCount(teamId, restrictions) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("TeamStore.GetActiveMemberCount", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("TeamStore.GetActiveMemberCount", success, elapsed) } return resultVar0, resultVar1 } @@ -5518,14 +5213,13 @@ func (s *TimerLayerTeamStore) GetAll() ([]*model.Team, *model.AppError) { resultVar0, resultVar1 := s.TeamStore.GetAll() - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("TeamStore.GetAll", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("TeamStore.GetAll", success, elapsed) } return resultVar0, resultVar1 } @@ -5535,14 +5229,13 @@ func (s *TimerLayerTeamStore) GetAllForExportAfter(limit int, afterId string) ([ resultVar0, resultVar1 := s.TeamStore.GetAllForExportAfter(limit, afterId) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("TeamStore.GetAllForExportAfter", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("TeamStore.GetAllForExportAfter", success, elapsed) } return resultVar0, resultVar1 } @@ -5552,14 +5245,13 @@ func (s *TimerLayerTeamStore) GetAllPage(offset int, limit int) ([]*model.Team, resultVar0, resultVar1 := s.TeamStore.GetAllPage(offset, limit) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("TeamStore.GetAllPage", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("TeamStore.GetAllPage", success, elapsed) } return resultVar0, resultVar1 } @@ -5569,14 +5261,13 @@ func (s *TimerLayerTeamStore) GetAllPrivateTeamListing() ([]*model.Team, *model. resultVar0, resultVar1 := s.TeamStore.GetAllPrivateTeamListing() - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("TeamStore.GetAllPrivateTeamListing", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("TeamStore.GetAllPrivateTeamListing", success, elapsed) } return resultVar0, resultVar1 } @@ -5586,14 +5277,13 @@ func (s *TimerLayerTeamStore) GetAllPrivateTeamPageListing(offset int, limit int resultVar0, resultVar1 := s.TeamStore.GetAllPrivateTeamPageListing(offset, limit) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("TeamStore.GetAllPrivateTeamPageListing", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("TeamStore.GetAllPrivateTeamPageListing", success, elapsed) } return resultVar0, resultVar1 } @@ -5603,14 +5293,13 @@ func (s *TimerLayerTeamStore) GetAllPublicTeamPageListing(offset int, limit int) resultVar0, resultVar1 := s.TeamStore.GetAllPublicTeamPageListing(offset, limit) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("TeamStore.GetAllPublicTeamPageListing", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("TeamStore.GetAllPublicTeamPageListing", success, elapsed) } return resultVar0, resultVar1 } @@ -5620,14 +5309,13 @@ func (s *TimerLayerTeamStore) GetAllTeamListing() ([]*model.Team, *model.AppErro resultVar0, resultVar1 := s.TeamStore.GetAllTeamListing() - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("TeamStore.GetAllTeamListing", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("TeamStore.GetAllTeamListing", success, elapsed) } return resultVar0, resultVar1 } @@ -5637,14 +5325,13 @@ func (s *TimerLayerTeamStore) GetAllTeamPageListing(offset int, limit int) ([]*m resultVar0, resultVar1 := s.TeamStore.GetAllTeamPageListing(offset, limit) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("TeamStore.GetAllTeamPageListing", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("TeamStore.GetAllTeamPageListing", success, elapsed) } return resultVar0, resultVar1 } @@ -5654,14 +5341,13 @@ func (s *TimerLayerTeamStore) GetByInviteId(inviteId string) (*model.Team, *mode resultVar0, resultVar1 := s.TeamStore.GetByInviteId(inviteId) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("TeamStore.GetByInviteId", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("TeamStore.GetByInviteId", success, elapsed) } return resultVar0, resultVar1 } @@ -5671,14 +5357,13 @@ func (s *TimerLayerTeamStore) GetByName(name string) (*model.Team, *model.AppErr resultVar0, resultVar1 := s.TeamStore.GetByName(name) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("TeamStore.GetByName", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("TeamStore.GetByName", success, elapsed) } return resultVar0, resultVar1 } @@ -5688,14 +5373,13 @@ func (s *TimerLayerTeamStore) GetChannelUnreadsForAllTeams(excludeTeamId string, resultVar0, resultVar1 := s.TeamStore.GetChannelUnreadsForAllTeams(excludeTeamId, userId) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("TeamStore.GetChannelUnreadsForAllTeams", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("TeamStore.GetChannelUnreadsForAllTeams", success, elapsed) } return resultVar0, resultVar1 } @@ -5705,14 +5389,13 @@ func (s *TimerLayerTeamStore) GetChannelUnreadsForTeam(teamId string, userId str resultVar0, resultVar1 := s.TeamStore.GetChannelUnreadsForTeam(teamId, userId) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("TeamStore.GetChannelUnreadsForTeam", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("TeamStore.GetChannelUnreadsForTeam", success, elapsed) } return resultVar0, resultVar1 } @@ -5722,14 +5405,13 @@ func (s *TimerLayerTeamStore) GetMember(teamId string, userId string) (*model.Te resultVar0, resultVar1 := s.TeamStore.GetMember(teamId, userId) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("TeamStore.GetMember", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("TeamStore.GetMember", success, elapsed) } return resultVar0, resultVar1 } @@ -5739,14 +5421,13 @@ func (s *TimerLayerTeamStore) GetMembers(teamId string, offset int, limit int, r resultVar0, resultVar1 := s.TeamStore.GetMembers(teamId, offset, limit, restrictions) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("TeamStore.GetMembers", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("TeamStore.GetMembers", success, elapsed) } return resultVar0, resultVar1 } @@ -5756,14 +5437,13 @@ func (s *TimerLayerTeamStore) GetMembersByIds(teamId string, userIds []string, r resultVar0, resultVar1 := s.TeamStore.GetMembersByIds(teamId, userIds, restrictions) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("TeamStore.GetMembersByIds", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("TeamStore.GetMembersByIds", success, elapsed) } return resultVar0, resultVar1 } @@ -5773,14 +5453,13 @@ func (s *TimerLayerTeamStore) GetTeamMembersForExport(userId string) ([]*model.T resultVar0, resultVar1 := s.TeamStore.GetTeamMembersForExport(userId) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("TeamStore.GetTeamMembersForExport", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("TeamStore.GetTeamMembersForExport", success, elapsed) } return resultVar0, resultVar1 } @@ -5790,14 +5469,13 @@ func (s *TimerLayerTeamStore) GetTeamsByScheme(schemeId string, offset int, limi resultVar0, resultVar1 := s.TeamStore.GetTeamsByScheme(schemeId, offset, limit) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("TeamStore.GetTeamsByScheme", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("TeamStore.GetTeamsByScheme", success, elapsed) } return resultVar0, resultVar1 } @@ -5807,14 +5485,13 @@ func (s *TimerLayerTeamStore) GetTeamsByUserId(userId string) ([]*model.Team, *m resultVar0, resultVar1 := s.TeamStore.GetTeamsByUserId(userId) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("TeamStore.GetTeamsByUserId", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("TeamStore.GetTeamsByUserId", success, elapsed) } return resultVar0, resultVar1 } @@ -5824,14 +5501,13 @@ func (s *TimerLayerTeamStore) GetTeamsForUser(userId string) ([]*model.TeamMembe resultVar0, resultVar1 := s.TeamStore.GetTeamsForUser(userId) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("TeamStore.GetTeamsForUser", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("TeamStore.GetTeamsForUser", success, elapsed) } return resultVar0, resultVar1 } @@ -5841,14 +5517,13 @@ func (s *TimerLayerTeamStore) GetTeamsForUserWithPagination(userId string, page resultVar0, resultVar1 := s.TeamStore.GetTeamsForUserWithPagination(userId, page, perPage) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("TeamStore.GetTeamsForUserWithPagination", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("TeamStore.GetTeamsForUserWithPagination", success, elapsed) } return resultVar0, resultVar1 } @@ -5858,14 +5533,13 @@ func (s *TimerLayerTeamStore) GetTotalMemberCount(teamId string, restrictions *m resultVar0, resultVar1 := s.TeamStore.GetTotalMemberCount(teamId, restrictions) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("TeamStore.GetTotalMemberCount", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("TeamStore.GetTotalMemberCount", success, elapsed) } return resultVar0, resultVar1 } @@ -5875,14 +5549,13 @@ func (s *TimerLayerTeamStore) GetUserTeamIds(userId string, allowFromCache bool) resultVar0, resultVar1 := s.TeamStore.GetUserTeamIds(userId, allowFromCache) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("TeamStore.GetUserTeamIds", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("TeamStore.GetUserTeamIds", success, elapsed) } return resultVar0, resultVar1 } @@ -5892,14 +5565,13 @@ func (s *TimerLayerTeamStore) InvalidateAllTeamIdsForUser(userId string) { s.TeamStore.InvalidateAllTeamIdsForUser(userId) - t := timemodule.Now() - elapsed := t.Sub(start) + 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, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("TeamStore.InvalidateAllTeamIdsForUser", success, elapsed) } return } @@ -5909,14 +5581,13 @@ func (s *TimerLayerTeamStore) MigrateTeamMembers(fromTeamId string, fromUserId s resultVar0, resultVar1 := s.TeamStore.MigrateTeamMembers(fromTeamId, fromUserId) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("TeamStore.MigrateTeamMembers", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("TeamStore.MigrateTeamMembers", success, elapsed) } return resultVar0, resultVar1 } @@ -5926,14 +5597,13 @@ func (s *TimerLayerTeamStore) PermanentDelete(teamId string) *model.AppError { resultVar0 := s.TeamStore.PermanentDelete(teamId) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar0 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("TeamStore.PermanentDelete", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("TeamStore.PermanentDelete", success, elapsed) } return resultVar0 } @@ -5943,14 +5613,13 @@ func (s *TimerLayerTeamStore) RemoveAllMembersByTeam(teamId string) *model.AppEr resultVar0 := s.TeamStore.RemoveAllMembersByTeam(teamId) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar0 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("TeamStore.RemoveAllMembersByTeam", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("TeamStore.RemoveAllMembersByTeam", success, elapsed) } return resultVar0 } @@ -5960,14 +5629,13 @@ func (s *TimerLayerTeamStore) RemoveAllMembersByUser(userId string) *model.AppEr resultVar0 := s.TeamStore.RemoveAllMembersByUser(userId) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar0 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("TeamStore.RemoveAllMembersByUser", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("TeamStore.RemoveAllMembersByUser", success, elapsed) } return resultVar0 } @@ -5977,14 +5645,13 @@ func (s *TimerLayerTeamStore) RemoveMember(teamId string, userId string) *model. resultVar0 := s.TeamStore.RemoveMember(teamId, userId) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar0 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("TeamStore.RemoveMember", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("TeamStore.RemoveMember", success, elapsed) } return resultVar0 } @@ -5994,14 +5661,13 @@ func (s *TimerLayerTeamStore) ResetAllTeamSchemes() *model.AppError { resultVar0 := s.TeamStore.ResetAllTeamSchemes() - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar0 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("TeamStore.ResetAllTeamSchemes", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("TeamStore.ResetAllTeamSchemes", success, elapsed) } return resultVar0 } @@ -6011,14 +5677,13 @@ func (s *TimerLayerTeamStore) Save(team *model.Team) (*model.Team, *model.AppErr resultVar0, resultVar1 := s.TeamStore.Save(team) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("TeamStore.Save", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("TeamStore.Save", success, elapsed) } return resultVar0, resultVar1 } @@ -6028,14 +5693,13 @@ func (s *TimerLayerTeamStore) SaveMember(member *model.TeamMember, maxUsersPerTe resultVar0, resultVar1 := s.TeamStore.SaveMember(member, maxUsersPerTeam) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("TeamStore.SaveMember", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("TeamStore.SaveMember", success, elapsed) } return resultVar0, resultVar1 } @@ -6045,14 +5709,13 @@ func (s *TimerLayerTeamStore) SearchAll(term string) ([]*model.Team, *model.AppE resultVar0, resultVar1 := s.TeamStore.SearchAll(term) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("TeamStore.SearchAll", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("TeamStore.SearchAll", success, elapsed) } return resultVar0, resultVar1 } @@ -6062,14 +5725,13 @@ func (s *TimerLayerTeamStore) SearchOpen(term string) ([]*model.Team, *model.App resultVar0, resultVar1 := s.TeamStore.SearchOpen(term) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("TeamStore.SearchOpen", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("TeamStore.SearchOpen", success, elapsed) } return resultVar0, resultVar1 } @@ -6079,14 +5741,13 @@ func (s *TimerLayerTeamStore) SearchPrivate(term string) ([]*model.Team, *model. resultVar0, resultVar1 := s.TeamStore.SearchPrivate(term) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("TeamStore.SearchPrivate", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("TeamStore.SearchPrivate", success, elapsed) } return resultVar0, resultVar1 } @@ -6096,14 +5757,13 @@ func (s *TimerLayerTeamStore) Update(team *model.Team) (*model.Team, *model.AppE resultVar0, resultVar1 := s.TeamStore.Update(team) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("TeamStore.Update", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("TeamStore.Update", success, elapsed) } return resultVar0, resultVar1 } @@ -6113,14 +5773,13 @@ func (s *TimerLayerTeamStore) UpdateLastTeamIconUpdate(teamId string, curTime in resultVar0 := s.TeamStore.UpdateLastTeamIconUpdate(teamId, curTime) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar0 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("TeamStore.UpdateLastTeamIconUpdate", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("TeamStore.UpdateLastTeamIconUpdate", success, elapsed) } return resultVar0 } @@ -6130,14 +5789,13 @@ func (s *TimerLayerTeamStore) UpdateMember(member *model.TeamMember) (*model.Tea resultVar0, resultVar1 := s.TeamStore.UpdateMember(member) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("TeamStore.UpdateMember", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("TeamStore.UpdateMember", success, elapsed) } return resultVar0, resultVar1 } @@ -6147,14 +5805,13 @@ func (s *TimerLayerTeamStore) UserBelongsToTeams(userId string, teamIds []string resultVar0, resultVar1 := s.TeamStore.UserBelongsToTeams(userId, teamIds) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("TeamStore.UserBelongsToTeams", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("TeamStore.UserBelongsToTeams", success, elapsed) } return resultVar0, resultVar1 } @@ -6164,14 +5821,13 @@ func (s *TimerLayerTermsOfServiceStore) Get(id string, allowFromCache bool) (*mo resultVar0, resultVar1 := s.TermsOfServiceStore.Get(id, allowFromCache) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("TermsOfServiceStore.Get", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("TermsOfServiceStore.Get", success, elapsed) } return resultVar0, resultVar1 } @@ -6181,14 +5837,13 @@ func (s *TimerLayerTermsOfServiceStore) GetLatest(allowFromCache bool) (*model.T resultVar0, resultVar1 := s.TermsOfServiceStore.GetLatest(allowFromCache) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("TermsOfServiceStore.GetLatest", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("TermsOfServiceStore.GetLatest", success, elapsed) } return resultVar0, resultVar1 } @@ -6198,14 +5853,13 @@ func (s *TimerLayerTermsOfServiceStore) Save(termsOfService *model.TermsOfServic resultVar0, resultVar1 := s.TermsOfServiceStore.Save(termsOfService) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("TermsOfServiceStore.Save", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("TermsOfServiceStore.Save", success, elapsed) } return resultVar0, resultVar1 } @@ -6215,14 +5869,13 @@ func (s *TimerLayerTokenStore) Cleanup() { s.TokenStore.Cleanup() - t := timemodule.Now() - elapsed := t.Sub(start) + 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, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("TokenStore.Cleanup", success, elapsed) } return } @@ -6232,14 +5885,13 @@ func (s *TimerLayerTokenStore) Delete(token string) *model.AppError { resultVar0 := s.TokenStore.Delete(token) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar0 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("TokenStore.Delete", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("TokenStore.Delete", success, elapsed) } return resultVar0 } @@ -6249,14 +5901,13 @@ func (s *TimerLayerTokenStore) GetByToken(token string) (*model.Token, *model.Ap resultVar0, resultVar1 := s.TokenStore.GetByToken(token) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("TokenStore.GetByToken", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("TokenStore.GetByToken", success, elapsed) } return resultVar0, resultVar1 } @@ -6266,14 +5917,13 @@ func (s *TimerLayerTokenStore) RemoveAllTokensByType(tokenType string) *model.Ap resultVar0 := s.TokenStore.RemoveAllTokensByType(tokenType) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar0 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("TokenStore.RemoveAllTokensByType", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("TokenStore.RemoveAllTokensByType", success, elapsed) } return resultVar0 } @@ -6283,14 +5933,13 @@ func (s *TimerLayerTokenStore) Save(recovery *model.Token) *model.AppError { resultVar0 := s.TokenStore.Save(recovery) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar0 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("TokenStore.Save", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("TokenStore.Save", success, elapsed) } return resultVar0 } @@ -6300,14 +5949,13 @@ func (s *TimerLayerUserStore) AnalyticsActiveCount(time int64, options model.Use resultVar0, resultVar1 := s.UserStore.AnalyticsActiveCount(time, options) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("UserStore.AnalyticsActiveCount", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("UserStore.AnalyticsActiveCount", success, elapsed) } return resultVar0, resultVar1 } @@ -6317,14 +5965,13 @@ func (s *TimerLayerUserStore) AnalyticsGetInactiveUsersCount() (int64, *model.Ap resultVar0, resultVar1 := s.UserStore.AnalyticsGetInactiveUsersCount() - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("UserStore.AnalyticsGetInactiveUsersCount", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("UserStore.AnalyticsGetInactiveUsersCount", success, elapsed) } return resultVar0, resultVar1 } @@ -6334,14 +5981,13 @@ func (s *TimerLayerUserStore) AnalyticsGetSystemAdminCount() (int64, *model.AppE resultVar0, resultVar1 := s.UserStore.AnalyticsGetSystemAdminCount() - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("UserStore.AnalyticsGetSystemAdminCount", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("UserStore.AnalyticsGetSystemAdminCount", success, elapsed) } return resultVar0, resultVar1 } @@ -6351,14 +5997,13 @@ func (s *TimerLayerUserStore) ClearAllCustomRoleAssignments() *model.AppError { resultVar0 := s.UserStore.ClearAllCustomRoleAssignments() - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar0 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("UserStore.ClearAllCustomRoleAssignments", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("UserStore.ClearAllCustomRoleAssignments", success, elapsed) } return resultVar0 } @@ -6368,14 +6013,13 @@ func (s *TimerLayerUserStore) ClearCaches() { s.UserStore.ClearCaches() - t := timemodule.Now() - elapsed := t.Sub(start) + 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, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("UserStore.ClearCaches", success, elapsed) } return } @@ -6385,14 +6029,13 @@ func (s *TimerLayerUserStore) Count(options model.UserCountOptions) (int64, *mod resultVar0, resultVar1 := s.UserStore.Count(options) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("UserStore.Count", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("UserStore.Count", success, elapsed) } return resultVar0, resultVar1 } @@ -6402,14 +6045,13 @@ func (s *TimerLayerUserStore) DemoteUserToGuest(userID string) *model.AppError { resultVar0 := s.UserStore.DemoteUserToGuest(userID) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar0 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("UserStore.DemoteUserToGuest", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("UserStore.DemoteUserToGuest", success, elapsed) } return resultVar0 } @@ -6419,14 +6061,13 @@ func (s *TimerLayerUserStore) Get(id string) (*model.User, *model.AppError) { resultVar0, resultVar1 := s.UserStore.Get(id) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("UserStore.Get", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("UserStore.Get", success, elapsed) } return resultVar0, resultVar1 } @@ -6436,14 +6077,13 @@ func (s *TimerLayerUserStore) GetAll() ([]*model.User, *model.AppError) { resultVar0, resultVar1 := s.UserStore.GetAll() - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("UserStore.GetAll", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("UserStore.GetAll", success, elapsed) } return resultVar0, resultVar1 } @@ -6453,14 +6093,13 @@ func (s *TimerLayerUserStore) GetAllAfter(limit int, afterId string) ([]*model.U resultVar0, resultVar1 := s.UserStore.GetAllAfter(limit, afterId) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("UserStore.GetAllAfter", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("UserStore.GetAllAfter", success, elapsed) } return resultVar0, resultVar1 } @@ -6470,14 +6109,13 @@ func (s *TimerLayerUserStore) GetAllProfiles(options *model.UserGetOptions) ([]* resultVar0, resultVar1 := s.UserStore.GetAllProfiles(options) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("UserStore.GetAllProfiles", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("UserStore.GetAllProfiles", success, elapsed) } return resultVar0, resultVar1 } @@ -6487,14 +6125,13 @@ func (s *TimerLayerUserStore) GetAllProfilesInChannel(channelId string, allowFro resultVar0, resultVar1 := s.UserStore.GetAllProfilesInChannel(channelId, allowFromCache) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("UserStore.GetAllProfilesInChannel", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("UserStore.GetAllProfilesInChannel", success, elapsed) } return resultVar0, resultVar1 } @@ -6504,14 +6141,13 @@ func (s *TimerLayerUserStore) GetAllUsingAuthService(authService string) ([]*mod resultVar0, resultVar1 := s.UserStore.GetAllUsingAuthService(authService) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("UserStore.GetAllUsingAuthService", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("UserStore.GetAllUsingAuthService", success, elapsed) } return resultVar0, resultVar1 } @@ -6521,14 +6157,13 @@ func (s *TimerLayerUserStore) GetAnyUnreadPostCountForChannel(userId string, cha resultVar0, resultVar1 := s.UserStore.GetAnyUnreadPostCountForChannel(userId, channelId) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("UserStore.GetAnyUnreadPostCountForChannel", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("UserStore.GetAnyUnreadPostCountForChannel", success, elapsed) } return resultVar0, resultVar1 } @@ -6538,14 +6173,13 @@ func (s *TimerLayerUserStore) GetByAuth(authData *string, authService string) (* resultVar0, resultVar1 := s.UserStore.GetByAuth(authData, authService) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("UserStore.GetByAuth", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("UserStore.GetByAuth", success, elapsed) } return resultVar0, resultVar1 } @@ -6555,14 +6189,13 @@ func (s *TimerLayerUserStore) GetByEmail(email string) (*model.User, *model.AppE resultVar0, resultVar1 := s.UserStore.GetByEmail(email) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("UserStore.GetByEmail", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("UserStore.GetByEmail", success, elapsed) } return resultVar0, resultVar1 } @@ -6572,14 +6205,13 @@ func (s *TimerLayerUserStore) GetByUsername(username string) (*model.User, *mode resultVar0, resultVar1 := s.UserStore.GetByUsername(username) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("UserStore.GetByUsername", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("UserStore.GetByUsername", success, elapsed) } return resultVar0, resultVar1 } @@ -6589,14 +6221,13 @@ func (s *TimerLayerUserStore) GetChannelGroupUsers(channelID string) ([]*model.U resultVar0, resultVar1 := s.UserStore.GetChannelGroupUsers(channelID) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("UserStore.GetChannelGroupUsers", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("UserStore.GetChannelGroupUsers", success, elapsed) } return resultVar0, resultVar1 } @@ -6606,14 +6237,13 @@ func (s *TimerLayerUserStore) GetEtagForAllProfiles() string { resultVar0 := s.UserStore.GetEtagForAllProfiles() - t := timemodule.Now() - elapsed := t.Sub(start) + 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, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("UserStore.GetEtagForAllProfiles", success, elapsed) } return resultVar0 } @@ -6623,14 +6253,13 @@ func (s *TimerLayerUserStore) GetEtagForProfiles(teamId string) string { resultVar0 := s.UserStore.GetEtagForProfiles(teamId) - t := timemodule.Now() - elapsed := t.Sub(start) + 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, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("UserStore.GetEtagForProfiles", success, elapsed) } return resultVar0 } @@ -6640,14 +6269,13 @@ func (s *TimerLayerUserStore) GetEtagForProfilesNotInTeam(teamId string) string resultVar0 := s.UserStore.GetEtagForProfilesNotInTeam(teamId) - t := timemodule.Now() - elapsed := t.Sub(start) + 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, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("UserStore.GetEtagForProfilesNotInTeam", success, elapsed) } return resultVar0 } @@ -6657,14 +6285,13 @@ func (s *TimerLayerUserStore) GetForLogin(loginId string, allowSignInWithUsernam resultVar0, resultVar1 := s.UserStore.GetForLogin(loginId, allowSignInWithUsername, allowSignInWithEmail) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("UserStore.GetForLogin", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("UserStore.GetForLogin", success, elapsed) } return resultVar0, resultVar1 } @@ -6674,14 +6301,13 @@ func (s *TimerLayerUserStore) GetNewUsersForTeam(teamId string, offset int, limi resultVar0, resultVar1 := s.UserStore.GetNewUsersForTeam(teamId, offset, limit, viewRestrictions) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("UserStore.GetNewUsersForTeam", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("UserStore.GetNewUsersForTeam", success, elapsed) } return resultVar0, resultVar1 } @@ -6691,14 +6317,13 @@ func (s *TimerLayerUserStore) GetProfileByGroupChannelIdsForUser(userId string, resultVar0, resultVar1 := s.UserStore.GetProfileByGroupChannelIdsForUser(userId, channelIds) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("UserStore.GetProfileByGroupChannelIdsForUser", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("UserStore.GetProfileByGroupChannelIdsForUser", success, elapsed) } return resultVar0, resultVar1 } @@ -6708,14 +6333,13 @@ func (s *TimerLayerUserStore) GetProfileByIds(userIds []string, options *UserGet resultVar0, resultVar1 := s.UserStore.GetProfileByIds(userIds, options, allowFromCache) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("UserStore.GetProfileByIds", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("UserStore.GetProfileByIds", success, elapsed) } return resultVar0, resultVar1 } @@ -6725,14 +6349,13 @@ func (s *TimerLayerUserStore) GetProfiles(options *model.UserGetOptions) ([]*mod resultVar0, resultVar1 := s.UserStore.GetProfiles(options) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("UserStore.GetProfiles", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("UserStore.GetProfiles", success, elapsed) } return resultVar0, resultVar1 } @@ -6742,14 +6365,13 @@ func (s *TimerLayerUserStore) GetProfilesByUsernames(usernames []string, viewRes resultVar0, resultVar1 := s.UserStore.GetProfilesByUsernames(usernames, viewRestrictions) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("UserStore.GetProfilesByUsernames", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("UserStore.GetProfilesByUsernames", success, elapsed) } return resultVar0, resultVar1 } @@ -6759,14 +6381,13 @@ func (s *TimerLayerUserStore) GetProfilesInChannel(channelId string, offset int, resultVar0, resultVar1 := s.UserStore.GetProfilesInChannel(channelId, offset, limit) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("UserStore.GetProfilesInChannel", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("UserStore.GetProfilesInChannel", success, elapsed) } return resultVar0, resultVar1 } @@ -6776,14 +6397,13 @@ func (s *TimerLayerUserStore) GetProfilesInChannelByStatus(channelId string, off resultVar0, resultVar1 := s.UserStore.GetProfilesInChannelByStatus(channelId, offset, limit) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("UserStore.GetProfilesInChannelByStatus", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("UserStore.GetProfilesInChannelByStatus", success, elapsed) } return resultVar0, resultVar1 } @@ -6793,14 +6413,13 @@ func (s *TimerLayerUserStore) GetProfilesNotInChannel(teamId string, channelId s resultVar0, resultVar1 := s.UserStore.GetProfilesNotInChannel(teamId, channelId, groupConstrained, offset, limit, viewRestrictions) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("UserStore.GetProfilesNotInChannel", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("UserStore.GetProfilesNotInChannel", success, elapsed) } return resultVar0, resultVar1 } @@ -6810,14 +6429,13 @@ func (s *TimerLayerUserStore) GetProfilesNotInTeam(teamId string, groupConstrain resultVar0, resultVar1 := s.UserStore.GetProfilesNotInTeam(teamId, groupConstrained, offset, limit, viewRestrictions) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("UserStore.GetProfilesNotInTeam", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("UserStore.GetProfilesNotInTeam", success, elapsed) } return resultVar0, resultVar1 } @@ -6827,14 +6445,13 @@ func (s *TimerLayerUserStore) GetProfilesWithoutTeam(options *model.UserGetOptio resultVar0, resultVar1 := s.UserStore.GetProfilesWithoutTeam(options) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("UserStore.GetProfilesWithoutTeam", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("UserStore.GetProfilesWithoutTeam", success, elapsed) } return resultVar0, resultVar1 } @@ -6844,14 +6461,13 @@ func (s *TimerLayerUserStore) GetRecentlyActiveUsersForTeam(teamId string, offse resultVar0, resultVar1 := s.UserStore.GetRecentlyActiveUsersForTeam(teamId, offset, limit, viewRestrictions) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("UserStore.GetRecentlyActiveUsersForTeam", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("UserStore.GetRecentlyActiveUsersForTeam", success, elapsed) } return resultVar0, resultVar1 } @@ -6861,14 +6477,13 @@ func (s *TimerLayerUserStore) GetSystemAdminProfiles() (map[string]*model.User, resultVar0, resultVar1 := s.UserStore.GetSystemAdminProfiles() - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("UserStore.GetSystemAdminProfiles", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("UserStore.GetSystemAdminProfiles", success, elapsed) } return resultVar0, resultVar1 } @@ -6878,14 +6493,13 @@ func (s *TimerLayerUserStore) GetTeamGroupUsers(teamID string) ([]*model.User, * resultVar0, resultVar1 := s.UserStore.GetTeamGroupUsers(teamID) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("UserStore.GetTeamGroupUsers", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("UserStore.GetTeamGroupUsers", success, elapsed) } return resultVar0, resultVar1 } @@ -6895,14 +6509,13 @@ func (s *TimerLayerUserStore) GetUnreadCount(userId string) (int64, error) { resultVar0, resultVar1 := s.UserStore.GetUnreadCount(userId) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if true { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("UserStore.GetUnreadCount", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("UserStore.GetUnreadCount", success, elapsed) } return resultVar0, resultVar1 } @@ -6912,14 +6525,13 @@ func (s *TimerLayerUserStore) GetUnreadCountForChannel(userId string, channelId resultVar0, resultVar1 := s.UserStore.GetUnreadCountForChannel(userId, channelId) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("UserStore.GetUnreadCountForChannel", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("UserStore.GetUnreadCountForChannel", success, elapsed) } return resultVar0, resultVar1 } @@ -6929,14 +6541,13 @@ func (s *TimerLayerUserStore) GetUsersBatchForIndexing(startTime int64, endTime resultVar0, resultVar1 := s.UserStore.GetUsersBatchForIndexing(startTime, endTime, limit) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("UserStore.GetUsersBatchForIndexing", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("UserStore.GetUsersBatchForIndexing", success, elapsed) } return resultVar0, resultVar1 } @@ -6946,14 +6557,13 @@ func (s *TimerLayerUserStore) InferSystemInstallDate() (int64, *model.AppError) resultVar0, resultVar1 := s.UserStore.InferSystemInstallDate() - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("UserStore.InferSystemInstallDate", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("UserStore.InferSystemInstallDate", success, elapsed) } return resultVar0, resultVar1 } @@ -6963,14 +6573,13 @@ func (s *TimerLayerUserStore) InvalidatProfileCacheForUser(userId string) { s.UserStore.InvalidatProfileCacheForUser(userId) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if true { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("UserStore.InvalidatProfileCacheForUser", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("UserStore.InvalidatProfileCacheForUser", success, elapsed) } return } @@ -6980,14 +6589,13 @@ func (s *TimerLayerUserStore) InvalidateProfilesInChannelCache(channelId string) s.UserStore.InvalidateProfilesInChannelCache(channelId) - t := timemodule.Now() - elapsed := t.Sub(start) + 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, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("UserStore.InvalidateProfilesInChannelCache", success, elapsed) } return } @@ -6997,14 +6605,13 @@ func (s *TimerLayerUserStore) InvalidateProfilesInChannelCacheByUser(userId stri s.UserStore.InvalidateProfilesInChannelCacheByUser(userId) - t := timemodule.Now() - elapsed := t.Sub(start) + 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, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("UserStore.InvalidateProfilesInChannelCacheByUser", success, elapsed) } return } @@ -7014,14 +6621,13 @@ func (s *TimerLayerUserStore) PermanentDelete(userId string) *model.AppError { resultVar0 := s.UserStore.PermanentDelete(userId) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar0 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("UserStore.PermanentDelete", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("UserStore.PermanentDelete", success, elapsed) } return resultVar0 } @@ -7031,14 +6637,13 @@ func (s *TimerLayerUserStore) PromoteGuestToUser(userID string) *model.AppError resultVar0 := s.UserStore.PromoteGuestToUser(userID) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar0 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("UserStore.PromoteGuestToUser", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("UserStore.PromoteGuestToUser", success, elapsed) } return resultVar0 } @@ -7048,14 +6653,13 @@ func (s *TimerLayerUserStore) ResetLastPictureUpdate(userId string) *model.AppEr resultVar0 := s.UserStore.ResetLastPictureUpdate(userId) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar0 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("UserStore.ResetLastPictureUpdate", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("UserStore.ResetLastPictureUpdate", success, elapsed) } return resultVar0 } @@ -7065,14 +6669,13 @@ func (s *TimerLayerUserStore) Save(user *model.User) (*model.User, *model.AppErr resultVar0, resultVar1 := s.UserStore.Save(user) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("UserStore.Save", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("UserStore.Save", success, elapsed) } return resultVar0, resultVar1 } @@ -7082,14 +6685,13 @@ func (s *TimerLayerUserStore) Search(teamId string, term string, options *model. resultVar0, resultVar1 := s.UserStore.Search(teamId, term, options) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("UserStore.Search", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("UserStore.Search", success, elapsed) } return resultVar0, resultVar1 } @@ -7099,14 +6701,13 @@ func (s *TimerLayerUserStore) SearchInChannel(channelId string, term string, opt resultVar0, resultVar1 := s.UserStore.SearchInChannel(channelId, term, options) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("UserStore.SearchInChannel", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("UserStore.SearchInChannel", success, elapsed) } return resultVar0, resultVar1 } @@ -7116,14 +6717,13 @@ func (s *TimerLayerUserStore) SearchNotInChannel(teamId string, channelId string resultVar0, resultVar1 := s.UserStore.SearchNotInChannel(teamId, channelId, term, options) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("UserStore.SearchNotInChannel", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("UserStore.SearchNotInChannel", success, elapsed) } return resultVar0, resultVar1 } @@ -7133,14 +6733,13 @@ func (s *TimerLayerUserStore) SearchNotInTeam(notInTeamId string, term string, o resultVar0, resultVar1 := s.UserStore.SearchNotInTeam(notInTeamId, term, options) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("UserStore.SearchNotInTeam", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("UserStore.SearchNotInTeam", success, elapsed) } return resultVar0, resultVar1 } @@ -7150,14 +6749,13 @@ func (s *TimerLayerUserStore) SearchWithoutTeam(term string, options *model.User resultVar0, resultVar1 := s.UserStore.SearchWithoutTeam(term, options) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("UserStore.SearchWithoutTeam", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("UserStore.SearchWithoutTeam", success, elapsed) } return resultVar0, resultVar1 } @@ -7167,14 +6765,13 @@ func (s *TimerLayerUserStore) Update(user *model.User, allowRoleUpdate bool) (*m resultVar0, resultVar1 := s.UserStore.Update(user, allowRoleUpdate) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("UserStore.Update", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("UserStore.Update", success, elapsed) } return resultVar0, resultVar1 } @@ -7184,14 +6781,13 @@ func (s *TimerLayerUserStore) UpdateAuthData(userId string, service string, auth resultVar0, resultVar1 := s.UserStore.UpdateAuthData(userId, service, authData, email, resetMfa) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("UserStore.UpdateAuthData", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("UserStore.UpdateAuthData", success, elapsed) } return resultVar0, resultVar1 } @@ -7201,14 +6797,13 @@ func (s *TimerLayerUserStore) UpdateFailedPasswordAttempts(userId string, attemp resultVar0 := s.UserStore.UpdateFailedPasswordAttempts(userId, attempts) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar0 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("UserStore.UpdateFailedPasswordAttempts", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("UserStore.UpdateFailedPasswordAttempts", success, elapsed) } return resultVar0 } @@ -7218,14 +6813,13 @@ func (s *TimerLayerUserStore) UpdateLastPictureUpdate(userId string) *model.AppE resultVar0 := s.UserStore.UpdateLastPictureUpdate(userId) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar0 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("UserStore.UpdateLastPictureUpdate", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("UserStore.UpdateLastPictureUpdate", success, elapsed) } return resultVar0 } @@ -7235,14 +6829,13 @@ func (s *TimerLayerUserStore) UpdateMfaActive(userId string, active bool) *model resultVar0 := s.UserStore.UpdateMfaActive(userId, active) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar0 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("UserStore.UpdateMfaActive", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("UserStore.UpdateMfaActive", success, elapsed) } return resultVar0 } @@ -7252,14 +6845,13 @@ func (s *TimerLayerUserStore) UpdateMfaSecret(userId string, secret string) *mod resultVar0 := s.UserStore.UpdateMfaSecret(userId, secret) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar0 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("UserStore.UpdateMfaSecret", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("UserStore.UpdateMfaSecret", success, elapsed) } return resultVar0 } @@ -7269,14 +6861,13 @@ func (s *TimerLayerUserStore) UpdatePassword(userId string, newPassword string) resultVar0 := s.UserStore.UpdatePassword(userId, newPassword) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar0 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("UserStore.UpdatePassword", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("UserStore.UpdatePassword", success, elapsed) } return resultVar0 } @@ -7286,14 +6877,13 @@ func (s *TimerLayerUserStore) UpdateUpdateAt(userId string) (int64, *model.AppEr resultVar0, resultVar1 := s.UserStore.UpdateUpdateAt(userId) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("UserStore.UpdateUpdateAt", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("UserStore.UpdateUpdateAt", success, elapsed) } return resultVar0, resultVar1 } @@ -7303,14 +6893,13 @@ func (s *TimerLayerUserStore) VerifyEmail(userId string, email string) (string, resultVar0, resultVar1 := s.UserStore.VerifyEmail(userId, email) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("UserStore.VerifyEmail", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("UserStore.VerifyEmail", success, elapsed) } return resultVar0, resultVar1 } @@ -7320,14 +6909,13 @@ func (s *TimerLayerUserAccessTokenStore) Delete(tokenId string) *model.AppError resultVar0 := s.UserAccessTokenStore.Delete(tokenId) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar0 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("UserAccessTokenStore.Delete", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("UserAccessTokenStore.Delete", success, elapsed) } return resultVar0 } @@ -7337,14 +6925,13 @@ func (s *TimerLayerUserAccessTokenStore) DeleteAllForUser(userId string) *model. resultVar0 := s.UserAccessTokenStore.DeleteAllForUser(userId) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar0 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("UserAccessTokenStore.DeleteAllForUser", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("UserAccessTokenStore.DeleteAllForUser", success, elapsed) } return resultVar0 } @@ -7354,14 +6941,13 @@ func (s *TimerLayerUserAccessTokenStore) Get(tokenId string) (*model.UserAccessT resultVar0, resultVar1 := s.UserAccessTokenStore.Get(tokenId) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("UserAccessTokenStore.Get", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("UserAccessTokenStore.Get", success, elapsed) } return resultVar0, resultVar1 } @@ -7371,14 +6957,13 @@ func (s *TimerLayerUserAccessTokenStore) GetAll(offset int, limit int) ([]*model resultVar0, resultVar1 := s.UserAccessTokenStore.GetAll(offset, limit) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("UserAccessTokenStore.GetAll", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("UserAccessTokenStore.GetAll", success, elapsed) } return resultVar0, resultVar1 } @@ -7388,14 +6973,13 @@ func (s *TimerLayerUserAccessTokenStore) GetByToken(tokenString string) (*model. resultVar0, resultVar1 := s.UserAccessTokenStore.GetByToken(tokenString) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("UserAccessTokenStore.GetByToken", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("UserAccessTokenStore.GetByToken", success, elapsed) } return resultVar0, resultVar1 } @@ -7405,14 +6989,13 @@ func (s *TimerLayerUserAccessTokenStore) GetByUser(userId string, page int, perP resultVar0, resultVar1 := s.UserAccessTokenStore.GetByUser(userId, page, perPage) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("UserAccessTokenStore.GetByUser", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("UserAccessTokenStore.GetByUser", success, elapsed) } return resultVar0, resultVar1 } @@ -7422,14 +7005,13 @@ func (s *TimerLayerUserAccessTokenStore) Save(token *model.UserAccessToken) (*mo resultVar0, resultVar1 := s.UserAccessTokenStore.Save(token) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("UserAccessTokenStore.Save", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("UserAccessTokenStore.Save", success, elapsed) } return resultVar0, resultVar1 } @@ -7439,14 +7021,13 @@ func (s *TimerLayerUserAccessTokenStore) Search(term string) ([]*model.UserAcces resultVar0, resultVar1 := s.UserAccessTokenStore.Search(term) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("UserAccessTokenStore.Search", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("UserAccessTokenStore.Search", success, elapsed) } return resultVar0, resultVar1 } @@ -7456,14 +7037,13 @@ func (s *TimerLayerUserAccessTokenStore) UpdateTokenDisable(tokenId string) *mod resultVar0 := s.UserAccessTokenStore.UpdateTokenDisable(tokenId) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar0 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("UserAccessTokenStore.UpdateTokenDisable", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("UserAccessTokenStore.UpdateTokenDisable", success, elapsed) } return resultVar0 } @@ -7473,14 +7053,13 @@ func (s *TimerLayerUserAccessTokenStore) UpdateTokenEnable(tokenId string) *mode resultVar0 := s.UserAccessTokenStore.UpdateTokenEnable(tokenId) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar0 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("UserAccessTokenStore.UpdateTokenEnable", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("UserAccessTokenStore.UpdateTokenEnable", success, elapsed) } return resultVar0 } @@ -7490,14 +7069,13 @@ func (s *TimerLayerUserTermsOfServiceStore) Delete(userId string, termsOfService resultVar0 := s.UserTermsOfServiceStore.Delete(userId, termsOfServiceId) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar0 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("UserTermsOfServiceStore.Delete", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("UserTermsOfServiceStore.Delete", success, elapsed) } return resultVar0 } @@ -7507,14 +7085,13 @@ func (s *TimerLayerUserTermsOfServiceStore) GetByUser(userId string) (*model.Use resultVar0, resultVar1 := s.UserTermsOfServiceStore.GetByUser(userId) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("UserTermsOfServiceStore.GetByUser", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("UserTermsOfServiceStore.GetByUser", success, elapsed) } return resultVar0, resultVar1 } @@ -7524,14 +7101,13 @@ func (s *TimerLayerUserTermsOfServiceStore) Save(userTermsOfService *model.UserT resultVar0, resultVar1 := s.UserTermsOfServiceStore.Save(userTermsOfService) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("UserTermsOfServiceStore.Save", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("UserTermsOfServiceStore.Save", success, elapsed) } return resultVar0, resultVar1 } @@ -7541,14 +7117,13 @@ func (s *TimerLayerWebhookStore) AnalyticsIncomingCount(teamId string) (int64, * resultVar0, resultVar1 := s.WebhookStore.AnalyticsIncomingCount(teamId) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("WebhookStore.AnalyticsIncomingCount", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("WebhookStore.AnalyticsIncomingCount", success, elapsed) } return resultVar0, resultVar1 } @@ -7558,14 +7133,13 @@ func (s *TimerLayerWebhookStore) AnalyticsOutgoingCount(teamId string) (int64, * resultVar0, resultVar1 := s.WebhookStore.AnalyticsOutgoingCount(teamId) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("WebhookStore.AnalyticsOutgoingCount", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("WebhookStore.AnalyticsOutgoingCount", success, elapsed) } return resultVar0, resultVar1 } @@ -7575,14 +7149,13 @@ func (s *TimerLayerWebhookStore) ClearCaches() { s.WebhookStore.ClearCaches() - t := timemodule.Now() - elapsed := t.Sub(start) + 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, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("WebhookStore.ClearCaches", success, elapsed) } return } @@ -7592,14 +7165,13 @@ func (s *TimerLayerWebhookStore) DeleteIncoming(webhookId string, time int64) *m resultVar0 := s.WebhookStore.DeleteIncoming(webhookId, time) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar0 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("WebhookStore.DeleteIncoming", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("WebhookStore.DeleteIncoming", success, elapsed) } return resultVar0 } @@ -7609,14 +7181,13 @@ func (s *TimerLayerWebhookStore) DeleteOutgoing(webhookId string, time int64) *m resultVar0 := s.WebhookStore.DeleteOutgoing(webhookId, time) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar0 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("WebhookStore.DeleteOutgoing", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("WebhookStore.DeleteOutgoing", success, elapsed) } return resultVar0 } @@ -7626,14 +7197,13 @@ func (s *TimerLayerWebhookStore) GetIncoming(id string, allowFromCache bool) (*m resultVar0, resultVar1 := s.WebhookStore.GetIncoming(id, allowFromCache) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("WebhookStore.GetIncoming", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("WebhookStore.GetIncoming", success, elapsed) } return resultVar0, resultVar1 } @@ -7643,14 +7213,13 @@ func (s *TimerLayerWebhookStore) GetIncomingByChannel(channelId string) ([]*mode resultVar0, resultVar1 := s.WebhookStore.GetIncomingByChannel(channelId) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("WebhookStore.GetIncomingByChannel", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("WebhookStore.GetIncomingByChannel", success, elapsed) } return resultVar0, resultVar1 } @@ -7660,14 +7229,13 @@ func (s *TimerLayerWebhookStore) GetIncomingByTeam(teamId string, offset int, li resultVar0, resultVar1 := s.WebhookStore.GetIncomingByTeam(teamId, offset, limit) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("WebhookStore.GetIncomingByTeam", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("WebhookStore.GetIncomingByTeam", success, elapsed) } return resultVar0, resultVar1 } @@ -7677,14 +7245,13 @@ func (s *TimerLayerWebhookStore) GetIncomingByTeamByUser(teamId string, userId s resultVar0, resultVar1 := s.WebhookStore.GetIncomingByTeamByUser(teamId, userId, offset, limit) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("WebhookStore.GetIncomingByTeamByUser", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("WebhookStore.GetIncomingByTeamByUser", success, elapsed) } return resultVar0, resultVar1 } @@ -7694,14 +7261,13 @@ func (s *TimerLayerWebhookStore) GetIncomingList(offset int, limit int) ([]*mode resultVar0, resultVar1 := s.WebhookStore.GetIncomingList(offset, limit) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("WebhookStore.GetIncomingList", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("WebhookStore.GetIncomingList", success, elapsed) } return resultVar0, resultVar1 } @@ -7711,14 +7277,13 @@ func (s *TimerLayerWebhookStore) GetIncomingListByUser(userId string, offset int resultVar0, resultVar1 := s.WebhookStore.GetIncomingListByUser(userId, offset, limit) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("WebhookStore.GetIncomingListByUser", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("WebhookStore.GetIncomingListByUser", success, elapsed) } return resultVar0, resultVar1 } @@ -7728,14 +7293,13 @@ func (s *TimerLayerWebhookStore) GetOutgoing(id string) (*model.OutgoingWebhook, resultVar0, resultVar1 := s.WebhookStore.GetOutgoing(id) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("WebhookStore.GetOutgoing", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("WebhookStore.GetOutgoing", success, elapsed) } return resultVar0, resultVar1 } @@ -7745,14 +7309,13 @@ func (s *TimerLayerWebhookStore) GetOutgoingByChannel(channelId string, offset i resultVar0, resultVar1 := s.WebhookStore.GetOutgoingByChannel(channelId, offset, limit) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("WebhookStore.GetOutgoingByChannel", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("WebhookStore.GetOutgoingByChannel", success, elapsed) } return resultVar0, resultVar1 } @@ -7762,14 +7325,13 @@ func (s *TimerLayerWebhookStore) GetOutgoingByChannelByUser(channelId string, us resultVar0, resultVar1 := s.WebhookStore.GetOutgoingByChannelByUser(channelId, userId, offset, limit) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("WebhookStore.GetOutgoingByChannelByUser", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("WebhookStore.GetOutgoingByChannelByUser", success, elapsed) } return resultVar0, resultVar1 } @@ -7779,14 +7341,13 @@ func (s *TimerLayerWebhookStore) GetOutgoingByTeam(teamId string, offset int, li resultVar0, resultVar1 := s.WebhookStore.GetOutgoingByTeam(teamId, offset, limit) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("WebhookStore.GetOutgoingByTeam", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("WebhookStore.GetOutgoingByTeam", success, elapsed) } return resultVar0, resultVar1 } @@ -7796,14 +7357,13 @@ func (s *TimerLayerWebhookStore) GetOutgoingByTeamByUser(teamId string, userId s resultVar0, resultVar1 := s.WebhookStore.GetOutgoingByTeamByUser(teamId, userId, offset, limit) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("WebhookStore.GetOutgoingByTeamByUser", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("WebhookStore.GetOutgoingByTeamByUser", success, elapsed) } return resultVar0, resultVar1 } @@ -7813,14 +7373,13 @@ func (s *TimerLayerWebhookStore) GetOutgoingList(offset int, limit int) ([]*mode resultVar0, resultVar1 := s.WebhookStore.GetOutgoingList(offset, limit) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("WebhookStore.GetOutgoingList", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("WebhookStore.GetOutgoingList", success, elapsed) } return resultVar0, resultVar1 } @@ -7830,14 +7389,13 @@ func (s *TimerLayerWebhookStore) GetOutgoingListByUser(userId string, offset int resultVar0, resultVar1 := s.WebhookStore.GetOutgoingListByUser(userId, offset, limit) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("WebhookStore.GetOutgoingListByUser", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("WebhookStore.GetOutgoingListByUser", success, elapsed) } return resultVar0, resultVar1 } @@ -7847,14 +7405,13 @@ func (s *TimerLayerWebhookStore) InvalidateWebhookCache(webhook string) { s.WebhookStore.InvalidateWebhookCache(webhook) - t := timemodule.Now() - elapsed := t.Sub(start) + 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, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("WebhookStore.InvalidateWebhookCache", success, elapsed) } return } @@ -7864,14 +7421,13 @@ func (s *TimerLayerWebhookStore) PermanentDeleteIncomingByChannel(channelId stri resultVar0 := s.WebhookStore.PermanentDeleteIncomingByChannel(channelId) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar0 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("WebhookStore.PermanentDeleteIncomingByChannel", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("WebhookStore.PermanentDeleteIncomingByChannel", success, elapsed) } return resultVar0 } @@ -7881,14 +7437,13 @@ func (s *TimerLayerWebhookStore) PermanentDeleteIncomingByUser(userId string) *m resultVar0 := s.WebhookStore.PermanentDeleteIncomingByUser(userId) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar0 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("WebhookStore.PermanentDeleteIncomingByUser", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("WebhookStore.PermanentDeleteIncomingByUser", success, elapsed) } return resultVar0 } @@ -7898,14 +7453,13 @@ func (s *TimerLayerWebhookStore) PermanentDeleteOutgoingByChannel(channelId stri resultVar0 := s.WebhookStore.PermanentDeleteOutgoingByChannel(channelId) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar0 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("WebhookStore.PermanentDeleteOutgoingByChannel", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("WebhookStore.PermanentDeleteOutgoingByChannel", success, elapsed) } return resultVar0 } @@ -7915,14 +7469,13 @@ func (s *TimerLayerWebhookStore) PermanentDeleteOutgoingByUser(userId string) *m resultVar0 := s.WebhookStore.PermanentDeleteOutgoingByUser(userId) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar0 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("WebhookStore.PermanentDeleteOutgoingByUser", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("WebhookStore.PermanentDeleteOutgoingByUser", success, elapsed) } return resultVar0 } @@ -7932,14 +7485,13 @@ func (s *TimerLayerWebhookStore) SaveIncoming(webhook *model.IncomingWebhook) (* resultVar0, resultVar1 := s.WebhookStore.SaveIncoming(webhook) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("WebhookStore.SaveIncoming", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("WebhookStore.SaveIncoming", success, elapsed) } return resultVar0, resultVar1 } @@ -7949,14 +7501,13 @@ func (s *TimerLayerWebhookStore) SaveOutgoing(webhook *model.OutgoingWebhook) (* resultVar0, resultVar1 := s.WebhookStore.SaveOutgoing(webhook) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("WebhookStore.SaveOutgoing", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("WebhookStore.SaveOutgoing", success, elapsed) } return resultVar0, resultVar1 } @@ -7966,14 +7517,13 @@ func (s *TimerLayerWebhookStore) UpdateIncoming(webhook *model.IncomingWebhook) resultVar0, resultVar1 := s.WebhookStore.UpdateIncoming(webhook) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("WebhookStore.UpdateIncoming", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("WebhookStore.UpdateIncoming", success, elapsed) } return resultVar0, resultVar1 } @@ -7983,14 +7533,13 @@ func (s *TimerLayerWebhookStore) UpdateOutgoing(hook *model.OutgoingWebhook) (*m resultVar0, resultVar1 := s.WebhookStore.UpdateOutgoing(hook) - t := timemodule.Now() - elapsed := t.Sub(start) + elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil { success := "false" if resultVar1 == nil { success = "true" } - s.Root.Metrics.ObserveStoreMethodDuration("WebhookStore.UpdateOutgoing", success, float64(elapsed)) + s.Root.Metrics.ObserveStoreMethodDuration("WebhookStore.UpdateOutgoing", success, elapsed) } return resultVar0, resultVar1 } diff --git a/utils/license.go b/utils/license.go index d62e90fd40..9758ca1e0e 100644 --- a/utils/license.go +++ b/utils/license.go @@ -10,7 +10,6 @@ import ( "crypto/x509" "encoding/base64" "encoding/pem" - "fmt" "io/ioutil" "os" "path/filepath" @@ -37,7 +36,7 @@ func ValidateLicense(signed []byte) (bool, string) { _, err := base64.StdEncoding.Decode(decoded, signed) if err != nil { - mlog.Error(fmt.Sprintf("Encountered error decoding license, err=%v", err.Error())) + mlog.Error("Encountered error decoding license", mlog.Err(err)) return false, "" } @@ -58,7 +57,7 @@ func ValidateLicense(signed []byte) (bool, string) { public, err := x509.ParsePKIXPublicKey(block.Bytes) if err != nil { - mlog.Error(fmt.Sprintf("Encountered error signing license, err=%v", err.Error())) + mlog.Error("Encountered error signing license", mlog.Err(err)) return false, "" } @@ -70,7 +69,7 @@ func ValidateLicense(signed []byte) (bool, string) { err = rsa.VerifyPKCS1v15(rsaPublic, crypto.SHA512, d, signature) if err != nil { - mlog.Error(fmt.Sprintf("Invalid signature, err=%v", err.Error())) + mlog.Error("Invalid signature", mlog.Err(err)) return false, "" } @@ -81,15 +80,15 @@ func GetAndValidateLicenseFileFromDisk(location string) (*model.License, []byte) fileName := GetLicenseFileLocation(location) if _, err := os.Stat(fileName); err != nil { - mlog.Debug(fmt.Sprintf("We could not find the license key in the database or on disk at %v", fileName)) + mlog.Debug("We could not find the license key in the database or on disk at", mlog.String("filename", fileName)) return nil, nil } - mlog.Info(fmt.Sprintf("License key has not been uploaded. Loading license key from disk at %v", fileName)) + mlog.Info("License key has not been uploaded. Loading license key from disk at", mlog.String("filename", fileName)) licenseBytes := GetLicenseFileFromDisk(fileName) if success, licenseStr := ValidateLicense(licenseBytes); !success { - mlog.Error(fmt.Sprintf("Found license key at %v but it appears to be invalid.", fileName)) + mlog.Error("Found license key at %v but it appears to be invalid.", mlog.String("filename", fileName)) return nil, nil } else { return model.LicenseFromJson(strings.NewReader(licenseStr)), licenseBytes @@ -99,14 +98,14 @@ func GetAndValidateLicenseFileFromDisk(location string) (*model.License, []byte) func GetLicenseFileFromDisk(fileName string) []byte { file, err := os.Open(fileName) if err != nil { - mlog.Error(fmt.Sprintf("Failed to open license key from disk at %v err=%v", fileName, err.Error())) + mlog.Error("Failed to open license key from disk at", mlog.String("filename", fileName), mlog.Err(err)) return nil } defer file.Close() licenseBytes, err := ioutil.ReadAll(file) if err != nil { - mlog.Error(fmt.Sprintf("Failed to read license key from disk at %v err=%v", fileName, err.Error())) + mlog.Error("Failed to read license key from disk at", mlog.String("filename", fileName), mlog.Err(err)) return nil } diff --git a/utils/test_files_compiler.go b/utils/test_files_compiler.go index 7e4bb4a4a7..b58ad98bd2 100644 --- a/utils/test_files_compiler.go +++ b/utils/test_files_compiler.go @@ -5,11 +5,11 @@ package utils import ( "bytes" - "fmt" "io/ioutil" "os" "os/exec" "path/filepath" + "runtime" "strings" "testing" @@ -38,23 +38,13 @@ func CompileGo(t *testing.T, sourceCode, outputPath string) { err = ioutil.WriteFile(main, []byte(sourceCode), 0600) require.NoError(t, err) - if os.Getenv("GO111MODULE") != "off" { - var mattermostServerPath string - - // Generate a go.mod file relying on the local copy of the mattermost-server. - // testlib linked mattermost-server into the general temporary directory for this test. - mattermostServerPath, err = filepath.Abs("mattermost-server") - require.NoError(t, err) - - goMod(t, dir, "init", "mattermost.com/test") - goMod(t, dir, "edit", "-require", "github.com/mattermost/mattermost-server@v0.0.0") - goMod(t, dir, "edit", "-replace", fmt.Sprintf("github.com/mattermost/mattermost-server@v0.0.0=%s", mattermostServerPath)) - goMod(t, dir, "edit", "-replace", fmt.Sprintf("git.apache.org/thrift.git=%s", "github.com/apache/thrift@v0.0.0-20180902110319-2566ecd5d999")) - } + _, sourceFile, _, ok := runtime.Caller(0) + require.True(t, ok) + serverPath := filepath.Dir(filepath.Dir(sourceFile)) out := &bytes.Buffer{} - cmd := exec.Command("go", "build", "-o", outputPath, "main.go") - cmd.Dir = dir + cmd := exec.Command("go", "build", "-mod=vendor", "-o", outputPath, main) + cmd.Dir = serverPath cmd.Stdout = out cmd.Stderr = out err = cmd.Run()