MM-24674 Update channel members by group to look at distinct timezones correctly (#14673)
* MM-24674 Update channel members by group to look at distinct autoTimezone and manualTimezone. Instead of just doing a blanket distinct on the column since that returns more entries than expected * Use JSON extract instead of parsing text * Use single quotes in mysql query too * Dont need to prepend users on unambiguous column * Use json extract instead of shorthand * Dont count timezone if timezone default length * CI Co-authored-by: mattermod <mattermod@users.noreply.github.com>
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
77bee1d4f1
Коммит
4d40226e02
@@ -18,6 +18,7 @@ import (
|
||||
"github.com/mattermost/mattermost-server/v5/model"
|
||||
"github.com/mattermost/mattermost-server/v5/services/timezones"
|
||||
"github.com/mattermost/mattermost-server/v5/store"
|
||||
"github.com/mattermost/mattermost-server/v5/utils"
|
||||
)
|
||||
|
||||
type SqlSupplier interface {
|
||||
@@ -4335,13 +4336,13 @@ func testGetMemberCountsByGroup(t *testing.T, ss store.Store) {
|
||||
require.Equal(t, expectedMemberCounts, memberCounts)
|
||||
})
|
||||
|
||||
t.Run("returns memberCountsByGroup with timezones", func(t *testing.T) {
|
||||
t.Run("returns memberCountsByGroup with timezones when no timezones set", func(t *testing.T) {
|
||||
memberCounts, err = ss.Channel().GetMemberCountsByGroup(c1.Id, true)
|
||||
expectedMemberCounts := []*model.ChannelMemberCountByGroup{
|
||||
{
|
||||
GroupId: g1.Id,
|
||||
ChannelMemberCount: 1,
|
||||
ChannelMemberTimezonesCount: 1,
|
||||
ChannelMemberTimezonesCount: 0,
|
||||
},
|
||||
}
|
||||
require.Nil(t, err)
|
||||
@@ -4362,6 +4363,7 @@ func testGetMemberCountsByGroup(t *testing.T, ss store.Store) {
|
||||
timeZone := timezones.DefaultUserTimezone()
|
||||
if i == 1 {
|
||||
timeZone["manualTimezone"] = "EDT"
|
||||
timeZone["useAutomaticTimezone"] = "false"
|
||||
}
|
||||
|
||||
u := &model.User{
|
||||
@@ -4399,10 +4401,20 @@ func testGetMemberCountsByGroup(t *testing.T, ss store.Store) {
|
||||
// create 10 different users with 3 different timezones for group 3
|
||||
for i := 1; i <= 10; i++ {
|
||||
timeZone := timezones.DefaultUserTimezone()
|
||||
if i == 1 {
|
||||
|
||||
if i == 1 || i == 2 {
|
||||
timeZone["manualTimezone"] = "EDT"
|
||||
} else if i == 2 {
|
||||
timeZone["useAutomaticTimezone"] = "false"
|
||||
} else if i == 3 || i == 4 {
|
||||
timeZone["manualTimezone"] = "PST"
|
||||
timeZone["useAutomaticTimezone"] = "false"
|
||||
} else if i == 5 || i == 6 {
|
||||
timeZone["autoTimezone"] = "PST"
|
||||
timeZone["useAutomaticTimezone"] = "true"
|
||||
} else {
|
||||
// Give every user with auto timezone set to true a random manual timezone to ensure that manual timezone is not looked at if auto is set
|
||||
timeZone["useAutomaticTimezone"] = "true"
|
||||
timeZone["manualTimezone"] = "PST" + utils.RandomName(utils.Range{Begin: 5, End: 5}, utils.ALPHANUMERIC)
|
||||
}
|
||||
|
||||
u := &model.User{
|
||||
@@ -4456,12 +4468,12 @@ func testGetMemberCountsByGroup(t *testing.T, ss store.Store) {
|
||||
{
|
||||
GroupId: g1.Id,
|
||||
ChannelMemberCount: 1,
|
||||
ChannelMemberTimezonesCount: 1,
|
||||
ChannelMemberTimezonesCount: 0,
|
||||
},
|
||||
{
|
||||
GroupId: g2.Id,
|
||||
ChannelMemberCount: 5,
|
||||
ChannelMemberTimezonesCount: 2,
|
||||
ChannelMemberTimezonesCount: 1,
|
||||
},
|
||||
{
|
||||
GroupId: g3.Id,
|
||||
|
||||
Ссылка в новой задаче
Block a user