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
@@ -1811,7 +1811,27 @@ func (s SqlChannelStore) GetMemberCountsByGroup(channelID string, includeTimezon
|
||||
selectStr := "GroupMembers.GroupId, COUNT(ChannelMembers.UserId) AS ChannelMemberCount"
|
||||
|
||||
if includeTimezones {
|
||||
selectStr = "GroupMembers.GroupId, COUNT(ChannelMembers.UserId) AS ChannelMemberCount, COUNT( DISTINCT Users.Timezone ) AS ChannelMemberTimezonesCount"
|
||||
distinctTimezones := `
|
||||
DISTINCT(
|
||||
CASE WHEN JSON_EXTRACT(Timezone, '$.useAutomaticTimezone') = 'true' AND LENGTH(Timezone) > 74
|
||||
THEN JSON_EXTRACT(Timezone, '$.automaticTimezone')
|
||||
WHEN LENGTH(Timezone) > 74
|
||||
THEN JSON_EXTRACT(Timezone, '$.manualTimezone')
|
||||
END
|
||||
)
|
||||
`
|
||||
if s.DriverName() == model.DATABASE_DRIVER_POSTGRES {
|
||||
distinctTimezones = `
|
||||
DISTINCT(
|
||||
CASE WHEN Timezone::json->>'useAutomaticTimezone' = 'true' AND LENGTH(Timezone) > 74
|
||||
THEN Timezone::json->>'automaticTimezone'
|
||||
WHEN LENGTH(Timezone) > 74
|
||||
THEN Timezone::json->>'manualTimezone'
|
||||
END
|
||||
)
|
||||
`
|
||||
}
|
||||
selectStr = `GroupMembers.GroupId, COUNT(ChannelMembers.UserId) AS ChannelMemberCount, COUNT(` + distinctTimezones + `) AS ChannelMemberTimezonesCount`
|
||||
}
|
||||
|
||||
query := s.getQueryBuilder().
|
||||
|
||||
Ссылка в новой задаче
Block a user