From 8ad99b4b1fbc901a69886d9a12ac016d8396b32f Mon Sep 17 00:00:00 2001 From: Joram Wilander Date: Fri, 9 Mar 2018 08:06:31 -0500 Subject: Remove query to update channel extra_update_at field on user activation/deactivation (#8415) --- app/user.go | 4 --- store/sqlstore/channel_store.go | 13 ---------- store/store.go | 1 - store/storetest/channel_store.go | 49 ----------------------------------- store/storetest/mocks/ChannelStore.go | 16 ------------ store/storetest/mocks/TeamStore.go | 20 +++++++------- 6 files changed, 10 insertions(+), 93 deletions(-) diff --git a/app/user.go b/app/user.go index dbce296d2..7a6dc0b49 100644 --- a/app/user.go +++ b/app/user.go @@ -914,10 +914,6 @@ func (a *App) UpdateActive(user *model.User, active bool) (*model.User, *model.A } } - if extra := <-a.Srv.Store.Channel().ExtraUpdateByUser(user.Id, model.GetMillis()); extra.Err != nil { - return nil, extra.Err - } - ruser := result.Data.([2]*model.User)[0] options := a.Config().GetSanitizeOptions() options["passwordupdate"] = false diff --git a/store/sqlstore/channel_store.go b/store/sqlstore/channel_store.go index c6d353959..e7a157192 100644 --- a/store/sqlstore/channel_store.go +++ b/store/sqlstore/channel_store.go @@ -1248,19 +1248,6 @@ func (s SqlChannelStore) AnalyticsDeletedTypeCount(teamId string, channelType st }) } -func (s SqlChannelStore) ExtraUpdateByUser(userId string, time int64) store.StoreChannel { - return store.Do(func(result *store.StoreResult) { - _, err := s.GetMaster().Exec( - `UPDATE Channels SET ExtraUpdateAt = :Time - WHERE Id IN (SELECT ChannelId FROM ChannelMembers WHERE UserId = :UserId);`, - map[string]interface{}{"UserId": userId, "Time": time}) - - if err != nil { - result.Err = model.NewAppError("SqlChannelStore.extraUpdated", "store.sql_channel.extra_updated.app_error", nil, "user_id="+userId+", "+err.Error(), http.StatusInternalServerError) - } - }) -} - func (s SqlChannelStore) GetMembersForUser(teamId string, userId string) store.StoreChannel { return store.Do(func(result *store.StoreResult) { members := &model.ChannelMembers{} diff --git a/store/store.go b/store/store.go index 671da02bd..f070a45db 100644 --- a/store/store.go +++ b/store/store.go @@ -153,7 +153,6 @@ type ChannelStore interface { UpdateLastViewedAt(channelIds []string, userId string) StoreChannel IncrementMentionCount(channelId string, userId string) StoreChannel AnalyticsTypeCount(teamId string, channelType string) StoreChannel - ExtraUpdateByUser(userId string, time int64) StoreChannel GetMembersForUser(teamId string, userId string) StoreChannel AutocompleteInTeam(teamId string, term string) StoreChannel SearchInTeam(teamId string, term string) StoreChannel diff --git a/store/storetest/channel_store.go b/store/storetest/channel_store.go index 121b40a01..d3b69edea 100644 --- a/store/storetest/channel_store.go +++ b/store/storetest/channel_store.go @@ -43,7 +43,6 @@ func TestChannelStore(t *testing.T, ss store.Store) { t.Run("GetMember", func(t *testing.T) { testGetMember(t, ss) }) t.Run("GetMemberForPost", func(t *testing.T) { testChannelStoreGetMemberForPost(t, ss) }) t.Run("GetMemberCount", func(t *testing.T) { testGetMemberCount(t, ss) }) - t.Run("UpdateExtrasByUser", func(t *testing.T) { testUpdateExtrasByUser(t, ss) }) t.Run("SearchMore", func(t *testing.T) { testChannelStoreSearchMore(t, ss) }) t.Run("SearchInTeam", func(t *testing.T) { testChannelStoreSearchInTeam(t, ss) }) t.Run("GetMembersByIds", func(t *testing.T) { testChannelStoreGetMembersByIds(t, ss) }) @@ -1641,54 +1640,6 @@ func testGetMemberCount(t *testing.T, ss store.Store) { } } -func testUpdateExtrasByUser(t *testing.T, ss store.Store) { - teamId := model.NewId() - - c1 := model.Channel{ - TeamId: teamId, - DisplayName: "Channel1", - Name: "zz" + model.NewId() + "b", - Type: model.CHANNEL_OPEN, - } - store.Must(ss.Channel().Save(&c1, -1)) - - c2 := model.Channel{ - TeamId: teamId, - DisplayName: "Channel2", - Name: "zz" + model.NewId() + "b", - Type: model.CHANNEL_OPEN, - } - store.Must(ss.Channel().Save(&c2, -1)) - - u1 := &model.User{ - Email: model.NewId(), - DeleteAt: 0, - } - store.Must(ss.User().Save(u1)) - store.Must(ss.Team().SaveMember(&model.TeamMember{TeamId: teamId, UserId: u1.Id}, -1)) - - m1 := model.ChannelMember{ - ChannelId: c1.Id, - UserId: u1.Id, - NotifyProps: model.GetDefaultChannelNotifyProps(), - } - store.Must(ss.Channel().SaveMember(&m1)) - - u1.DeleteAt = model.GetMillis() - store.Must(ss.User().Update(u1, true)) - - if result := <-ss.Channel().ExtraUpdateByUser(u1.Id, u1.DeleteAt); result.Err != nil { - t.Fatalf("failed to update extras by user: %v", result.Err) - } - - u1.DeleteAt = 0 - store.Must(ss.User().Update(u1, true)) - - if result := <-ss.Channel().ExtraUpdateByUser(u1.Id, u1.DeleteAt); result.Err != nil { - t.Fatalf("failed to update extras by user: %v", result.Err) - } -} - func testChannelStoreSearchMore(t *testing.T, ss store.Store) { o1 := model.Channel{} o1.TeamId = model.NewId() diff --git a/store/storetest/mocks/ChannelStore.go b/store/storetest/mocks/ChannelStore.go index 4ed3e39fb..6eab47073 100644 --- a/store/storetest/mocks/ChannelStore.go +++ b/store/storetest/mocks/ChannelStore.go @@ -98,22 +98,6 @@ func (_m *ChannelStore) Delete(channelId string, time int64) store.StoreChannel return r0 } -// ExtraUpdateByUser provides a mock function with given fields: userId, time -func (_m *ChannelStore) ExtraUpdateByUser(userId string, time int64) store.StoreChannel { - ret := _m.Called(userId, time) - - var r0 store.StoreChannel - if rf, ok := ret.Get(0).(func(string, int64) store.StoreChannel); ok { - r0 = rf(userId, time) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(store.StoreChannel) - } - } - - return r0 -} - // Get provides a mock function with given fields: id, allowFromCache func (_m *ChannelStore) Get(id string, allowFromCache bool) store.StoreChannel { ret := _m.Called(id, allowFromCache) diff --git a/store/storetest/mocks/TeamStore.go b/store/storetest/mocks/TeamStore.go index 8a7f030dc..d38fb5f27 100644 --- a/store/storetest/mocks/TeamStore.go +++ b/store/storetest/mocks/TeamStore.go @@ -461,13 +461,13 @@ func (_m *TeamStore) UpdateDisplayName(name string, teamId string) store.StoreCh return r0 } -// UpdateMember provides a mock function with given fields: member -func (_m *TeamStore) UpdateMember(member *model.TeamMember) store.StoreChannel { - ret := _m.Called(member) +// UpdateLastTeamIconUpdate provides a mock function with given fields: teamId, curTime +func (_m *TeamStore) UpdateLastTeamIconUpdate(teamId string, curTime int64) store.StoreChannel { + ret := _m.Called(teamId, curTime) var r0 store.StoreChannel - if rf, ok := ret.Get(0).(func(*model.TeamMember) store.StoreChannel); ok { - r0 = rf(member) + if rf, ok := ret.Get(0).(func(string, int64) store.StoreChannel); ok { + r0 = rf(teamId, curTime) } else { if ret.Get(0) != nil { r0 = ret.Get(0).(store.StoreChannel) @@ -477,13 +477,13 @@ func (_m *TeamStore) UpdateMember(member *model.TeamMember) store.StoreChannel { return r0 } -// UpdateLastTeamIconUpdate provides a mock function with given fields: teamId -func (_m *TeamStore) UpdateLastTeamIconUpdate(teamId string, curTime int64) store.StoreChannel { - ret := _m.Called(teamId) +// UpdateMember provides a mock function with given fields: member +func (_m *TeamStore) UpdateMember(member *model.TeamMember) store.StoreChannel { + ret := _m.Called(member) var r0 store.StoreChannel - if rf, ok := ret.Get(0).(func(string, int64) store.StoreChannel); ok { - r0 = rf(teamId, curTime) + if rf, ok := ret.Get(0).(func(*model.TeamMember) store.StoreChannel); ok { + r0 = rf(member) } else { if ret.Get(0) != nil { r0 = ret.Get(0).(store.StoreChannel) -- cgit v1.2.3-1-g7c22