[MM-55014][MM-55015] Add last login timestamp for users, add materialized view and refresh job to keep track of post stats for Postgres (#25152)
* [MM-55014][MM-55015] Add last login timestamp for users, add materialized view and refresh job for Postgres * Check fixes * Fix type issue * Add verification that lastlogin was updated * PR feedback * Morge'd * Morge'd again * Merge'd * Update admin setting strings * WIP * PR feedback * Oops * Fix i18n --------- Co-authored-by: Mattermost Build <build@mattermost.com>
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
41c08a3715
Коммит
1bd72bdb99
@@ -1308,6 +1308,20 @@ func (_m *UserStore) PromoteGuestToUser(userID string) error {
|
||||
return r0
|
||||
}
|
||||
|
||||
// RefreshPostStatsForUsers provides a mock function with given fields:
|
||||
func (_m *UserStore) RefreshPostStatsForUsers() error {
|
||||
ret := _m.Called()
|
||||
|
||||
var r0 error
|
||||
if rf, ok := ret.Get(0).(func() error); ok {
|
||||
r0 = rf()
|
||||
} else {
|
||||
r0 = ret.Error(0)
|
||||
}
|
||||
|
||||
return r0
|
||||
}
|
||||
|
||||
// ResetAuthDataToEmailForUsers provides a mock function with given fields: service, userIDs, includeDeleted, dryRun
|
||||
func (_m *UserStore) ResetAuthDataToEmailForUsers(service string, userIDs []string, includeDeleted bool, dryRun bool) (int, error) {
|
||||
ret := _m.Called(service, userIDs, includeDeleted, dryRun)
|
||||
@@ -1618,6 +1632,20 @@ func (_m *UserStore) UpdateFailedPasswordAttempts(userID string, attempts int) e
|
||||
return r0
|
||||
}
|
||||
|
||||
// UpdateLastLogin provides a mock function with given fields: userID, lastLogin
|
||||
func (_m *UserStore) UpdateLastLogin(userID string, lastLogin int64) error {
|
||||
ret := _m.Called(userID, lastLogin)
|
||||
|
||||
var r0 error
|
||||
if rf, ok := ret.Get(0).(func(string, int64) error); ok {
|
||||
r0 = rf(userID, lastLogin)
|
||||
} else {
|
||||
r0 = ret.Error(0)
|
||||
}
|
||||
|
||||
return r0
|
||||
}
|
||||
|
||||
// UpdateLastPictureUpdate provides a mock function with given fields: userID
|
||||
func (_m *UserStore) UpdateLastPictureUpdate(userID string) error {
|
||||
ret := _m.Called(userID)
|
||||
|
||||
@@ -95,6 +95,7 @@ func TestUserStore(t *testing.T, ss store.Store, s SqlStore) {
|
||||
t.Run("ResetLastPictureUpdate", func(t *testing.T) { testUserStoreResetLastPictureUpdate(t, ss) })
|
||||
t.Run("GetKnownUsers", func(t *testing.T) { testGetKnownUsers(t, ss) })
|
||||
t.Run("GetUsersWithInvalidEmails", func(t *testing.T) { testGetUsersWithInvalidEmails(t, ss) })
|
||||
t.Run("UpdateLastLogin", func(t *testing.T) { testUpdateLastLogin(t, ss) })
|
||||
}
|
||||
|
||||
func testUserStoreSave(t *testing.T, ss store.Store) {
|
||||
@@ -6169,3 +6170,18 @@ func testGetUsersWithInvalidEmails(t *testing.T, ss store.Store) {
|
||||
require.NoError(t, err)
|
||||
assert.Len(t, users, 1)
|
||||
}
|
||||
|
||||
func testUpdateLastLogin(t *testing.T, ss store.Store) {
|
||||
u1 := model.User{}
|
||||
u1.Email = MakeEmail()
|
||||
_, err := ss.User().Save(&u1)
|
||||
require.NoError(t, err)
|
||||
defer func() { require.NoError(t, ss.User().PermanentDelete(u1.Id)) }()
|
||||
|
||||
err = ss.User().UpdateLastLogin(u1.Id, 1234567890)
|
||||
require.NoError(t, err)
|
||||
|
||||
user, err := ss.User().Get(context.Background(), u1.Id)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, int64(1234567890), user.LastLogin)
|
||||
}
|
||||
|
||||
Ссылка в новой задаче
Block a user