[GH-19150] Remove strings in all channel types for constants (#19535)

Automatic Merge
Этот коммит содержится в:
Kitae Kim
2022-02-11 19:04:18 +09:00
коммит произвёл GitHub
родитель 0a17a9a6d8
Коммит ff288b488c
15 изменённых файлов: 74 добавлений и 70 удалений

Просмотреть файл

@@ -62,7 +62,7 @@ func TestChannelIsValid(t *testing.T) {
o.Type = "U"
require.NotNil(t, o.IsValid())
o.Type = "P"
o.Type = ChannelTypePrivate
require.Nil(t, o.IsValid())
o.Header = strings.Repeat("01234567890", 100)

Просмотреть файл

@@ -200,7 +200,7 @@ func (worker *BleveIndexerWorker) DoJob(job *model.Job) {
}
// Same possible fail as above can happen when counting channels
if count, err := worker.jobServer.Store.Channel().AnalyticsTypeCount("", "O"); err != nil {
if count, err := worker.jobServer.Store.Channel().AnalyticsTypeCount("", model.ChannelTypeOpen); err != nil {
mlog.Warn("Worker: Failed to fetch total channel count for job. An estimated value will be used for progress reporting.", mlog.String("workername", worker.name), mlog.String("job_id", job.Id), mlog.Err(err))
progress.TotalChannelsCount = EstimatedChannelCount
} else {

Просмотреть файл

@@ -117,7 +117,7 @@ func TestSlackParseChannels(t *testing.T) {
require.NoError(t, err)
defer file.Close()
channels, err := slackParseChannels(file, "O")
channels, err := slackParseChannels(file, model.ChannelTypeOpen)
require.NoError(t, err)
assert.Equal(t, 6, len(channels))
}
@@ -127,7 +127,7 @@ func TestSlackParseDirectMessages(t *testing.T) {
require.NoError(t, err)
defer file.Close()
channels, err := slackParseChannels(file, "D")
channels, err := slackParseChannels(file, model.ChannelTypeDirect)
require.NoError(t, err)
assert.Equal(t, 4, len(channels))
}
@@ -137,7 +137,7 @@ func TestSlackParsePrivateChannels(t *testing.T) {
require.NoError(t, err)
defer file.Close()
channels, err := slackParseChannels(file, "P")
channels, err := slackParseChannels(file, model.ChannelTypePrivate)
require.NoError(t, err)
assert.Equal(t, 1, len(channels))
}
@@ -147,7 +147,7 @@ func TestSlackParseGroupDirectMessages(t *testing.T) {
require.NoError(t, err)
defer file.Close()
channels, err := slackParseChannels(file, "G")
channels, err := slackParseChannels(file, model.ChannelTypeGroup)
require.NoError(t, err)
assert.Equal(t, 3, len(channels))
}
@@ -327,7 +327,7 @@ func TestOldImportChannel(t *testing.T) {
config.SetDefaults()
t.Run("No panic on direct channel", func(t *testing.T) {
//ch := th.CreateDmChannel(u1)
// ch := th.CreateDmChannel(u1)
ch := &model.Channel{
Type: model.ChannelTypeDirect,
Name: "test-channel",

Просмотреть файл

@@ -277,23 +277,23 @@ func (ts *TelemetryService) trackActivity() {
mlog.Info("Could not get team count", mlog.Err(err))
}
if ucc, err := ts.dbStore.Channel().AnalyticsTypeCount("", "O"); err == nil {
if ucc, err := ts.dbStore.Channel().AnalyticsTypeCount("", model.ChannelTypeOpen); err == nil {
publicChannelCount = ucc
}
if pcc, err := ts.dbStore.Channel().AnalyticsTypeCount("", "P"); err == nil {
if pcc, err := ts.dbStore.Channel().AnalyticsTypeCount("", model.ChannelTypePrivate); err == nil {
privateChannelCount = pcc
}
if dcc, err := ts.dbStore.Channel().AnalyticsTypeCount("", "D"); err == nil {
if dcc, err := ts.dbStore.Channel().AnalyticsTypeCount("", model.ChannelTypeDirect); err == nil {
directChannelCount = dcc
}
if duccr, err := ts.dbStore.Channel().AnalyticsDeletedTypeCount("", "O"); err == nil {
if duccr, err := ts.dbStore.Channel().AnalyticsDeletedTypeCount("", model.ChannelTypeOpen); err == nil {
deletedPublicChannelCount = duccr
}
if dpccr, err := ts.dbStore.Channel().AnalyticsDeletedTypeCount("", "P"); err == nil {
if dpccr, err := ts.dbStore.Channel().AnalyticsDeletedTypeCount("", model.ChannelTypePrivate); err == nil {
deletedPrivateChannelCount = dpccr
}

Просмотреть файл

@@ -107,8 +107,8 @@ func initializeMocks(cfg *model.Config) (*mocks.ServerIface, *storeMocks.Store,
channelStore.On("AnalyticsTypeCount", "", model.ChannelTypeOpen).Return(int64(25), nil)
channelStore.On("AnalyticsTypeCount", "", model.ChannelTypePrivate).Return(int64(26), nil)
channelStore.On("AnalyticsTypeCount", "", model.ChannelTypeDirect).Return(int64(27), nil)
channelStore.On("AnalyticsDeletedTypeCount", "", "O").Return(int64(22), nil)
channelStore.On("AnalyticsDeletedTypeCount", "", "P").Return(int64(23), nil)
channelStore.On("AnalyticsDeletedTypeCount", "", model.ChannelTypeOpen).Return(int64(22), nil)
channelStore.On("AnalyticsDeletedTypeCount", "", model.ChannelTypePrivate).Return(int64(23), nil)
channelStore.On("GroupSyncedChannelCount").Return(int64(17), nil)
postStore := storeMocks.PostStore{}

Просмотреть файл

@@ -534,7 +534,7 @@ func (s *OpenTracingLayerBotStore) Update(bot *model.Bot) (*model.Bot, error) {
return result, err
}
func (s *OpenTracingLayerChannelStore) AnalyticsDeletedTypeCount(teamID string, channelType string) (int64, error) {
func (s *OpenTracingLayerChannelStore) AnalyticsDeletedTypeCount(teamID string, channelType model.ChannelType) (int64, error) {
origCtx := s.Root.Store.Context()
span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "ChannelStore.AnalyticsDeletedTypeCount")
s.Root.Store.SetContext(newCtx)

Просмотреть файл

@@ -577,7 +577,7 @@ func (s *RetryLayerBotStore) Update(bot *model.Bot) (*model.Bot, error) {
}
func (s *RetryLayerChannelStore) AnalyticsDeletedTypeCount(teamID string, channelType string) (int64, error) {
func (s *RetryLayerChannelStore) AnalyticsDeletedTypeCount(teamID string, channelType model.ChannelType) (int64, error) {
tries := 0
for {

Просмотреть файл

@@ -693,7 +693,7 @@ func (s SqlChannelStore) saveChannelT(transaction *sqlxTxWrapper, channel *model
if channel.Type != model.ChannelTypeDirect && channel.Type != model.ChannelTypeGroup && maxChannelsPerTeam >= 0 {
var count int64
if err := transaction.Get(&count, "SELECT COUNT(0) FROM Channels WHERE TeamId = ? AND DeleteAt = 0 AND (Type = 'O' OR Type = 'P')", channel.TeamId); err != nil {
if err := transaction.Get(&count, "SELECT COUNT(0) FROM Channels WHERE TeamId = ? AND DeleteAt = 0 AND (Type = ? OR Type = ?)", channel.TeamId, model.ChannelTypeOpen, model.ChannelTypePrivate); err != nil {
return nil, errors.Wrapf(err, "save_channel_count: teamId=%s", channel.TeamId)
} else if count >= maxChannelsPerTeam {
return nil, store.NewErrLimitExceeded("channels_per_team", int(count), "teamId="+channel.TeamId)
@@ -1439,7 +1439,7 @@ func (s SqlChannelStore) GetChannelCounts(teamId string, userId string) (*model.
func (s SqlChannelStore) GetTeamChannels(teamId string) (model.ChannelList, error) {
data := model.ChannelList{}
err := s.GetReplicaX().Select(&data, "SELECT * FROM Channels WHERE TeamId = ? And Type != 'D' ORDER BY DisplayName", teamId)
err := s.GetReplicaX().Select(&data, "SELECT * FROM Channels WHERE TeamId = ? And Type != ? ORDER BY DisplayName", teamId, model.ChannelTypeDirect)
if err != nil {
return nil, errors.Wrapf(err, "failed to find Channels with teamId=%s", teamId)
}
@@ -1583,17 +1583,17 @@ func (s SqlChannelStore) GetDeleted(teamId string, offset int, limit int, userId
SELECT * FROM Channels
WHERE (TeamId = ? OR TeamId = '')
AND DeleteAt != 0
AND Type != 'P'
AND Type != ?
UNION
SELECT * FROM Channels
WHERE (TeamId = ? OR TeamId = '')
AND DeleteAt != 0
AND Type = 'P'
AND Type = ?
AND Id IN (SELECT ChannelId FROM ChannelMembers WHERE UserId = ?)
ORDER BY DisplayName LIMIT ? OFFSET ?
`
if err := s.GetReplicaX().Select(&channels, query, teamId, teamId, userId, limit, offset); err != nil {
if err := s.GetReplicaX().Select(&channels, query, teamId, model.ChannelTypePrivate, teamId, model.ChannelTypePrivate, userId, limit, offset); err != nil {
if err == sql.ErrNoRows {
return nil, store.NewErrNotFound("Channel", fmt.Sprintf("TeamId=%s,UserId=%s", teamId, userId))
}
@@ -2640,7 +2640,7 @@ func (s SqlChannelStore) IncrementMentionCount(channelId string, userId string,
func (s SqlChannelStore) GetAll(teamId string) ([]*model.Channel, error) {
data := []*model.Channel{}
err := s.GetReplicaX().Select(&data, "SELECT * FROM Channels WHERE TeamId = ? AND Type != 'D' ORDER BY Name", teamId)
err := s.GetReplicaX().Select(&data, "SELECT * FROM Channels WHERE TeamId = ? AND Type != ? ORDER BY Name", teamId, model.ChannelTypeDirect)
if err != nil {
return nil, errors.Wrapf(err, "failed to find Channels with teamId=%s", teamId)
@@ -2743,7 +2743,7 @@ func (s SqlChannelStore) AnalyticsTypeCount(teamId string, channelType model.Cha
return value, nil
}
func (s SqlChannelStore) AnalyticsDeletedTypeCount(teamId string, channelType string) (int64, error) {
func (s SqlChannelStore) AnalyticsDeletedTypeCount(teamId string, channelType model.ChannelType) (int64, error) {
query := s.getQueryBuilder().
Select("COUNT(Id) AS Value").
From("Channels").
@@ -2879,15 +2879,16 @@ func (s SqlChannelStore) Autocomplete(userID, term string, includeDeleted bool)
`+deleteFilter+`
SEARCH_CLAUSE
AND (
c.Type != 'P'
c.Type != :ChannelType
OR (
c.Type = 'P'
c.Type = :ChannelType
AND c.Id IN (SELECT ChannelId FROM ChannelMembers WHERE UserId = :UserId)
)
)
ORDER BY c.DisplayName
`, term, map[string]interface{}{
"UserId": userID,
"UserId": userID,
"ChannelType": model.ChannelTypePrivate,
})
}
@@ -2908,18 +2909,19 @@ func (s SqlChannelStore) AutocompleteInTeam(teamID, userID, term string, include
`+deleteFilter+`
SEARCH_CLAUSE
AND (
c.Type != 'P'
c.Type != :ChannelType
OR (
c.Type = 'P'
c.Type = :ChannelType
AND c.Id IN (SELECT ChannelId FROM ChannelMembers WHERE UserId = :UserId)
)
)
ORDER BY c.DisplayName
LIMIT :Limit
`, term, map[string]interface{}{
"TeamId": teamID,
"UserId": userID,
"Limit": model.ChannelSearchDefaultLimit,
"TeamId": teamID,
"UserId": userID,
"Limit": model.ChannelSearchDefaultLimit,
"ChannelType": model.ChannelTypePrivate,
})
}
@@ -2938,7 +2940,7 @@ func (s SqlChannelStore) AutocompleteInTeamForSearch(teamId string, userId strin
JOIN
ChannelMembers AS CM ON CM.ChannelId = C.Id
WHERE
(C.TeamId = :TeamId OR (C.TeamId = '' AND C.Type = 'G'))
(C.TeamId = :TeamId OR (C.TeamId = '' AND C.Type = :ChannelType))
AND CM.UserId = :UserId
` + deleteFilter + `
%v
@@ -2947,7 +2949,7 @@ func (s SqlChannelStore) AutocompleteInTeamForSearch(teamId string, userId strin
var channels model.ChannelList
if likeClause, likeTerm := s.buildLIKEClause(term, "Name, DisplayName, Purpose"); likeClause == "" {
if _, err := s.GetReplica().Select(&channels, fmt.Sprintf(queryFormat, ""), map[string]interface{}{"TeamId": teamId, "UserId": userId}); err != nil {
if _, err := s.GetReplica().Select(&channels, fmt.Sprintf(queryFormat, ""), map[string]interface{}{"TeamId": teamId, "UserId": userId, "ChannelType": model.ChannelTypeGroup}); err != nil {
return nil, errors.Wrapf(err, "failed to find Channels with term='%s'", term)
}
} else {
@@ -2958,7 +2960,7 @@ func (s SqlChannelStore) AutocompleteInTeamForSearch(teamId string, userId strin
fulltextQuery := fmt.Sprintf(queryFormat, "AND "+fulltextClause)
query := fmt.Sprintf("(%v) UNION (%v) LIMIT 50", likeQuery, fulltextQuery)
if _, err := s.GetReplica().Select(&channels, query, map[string]interface{}{"TeamId": teamId, "UserId": userId, "LikeTerm": likeTerm, "FulltextTerm": fulltextTerm}); err != nil {
if _, err := s.GetReplica().Select(&channels, query, map[string]interface{}{"TeamId": teamId, "UserId": userId, "LikeTerm": likeTerm, "FulltextTerm": fulltextTerm, "ChannelType": model.ChannelTypeGroup}); err != nil {
return nil, errors.Wrapf(err, "failed to find Channels with term='%s'", term)
}
}
@@ -2998,20 +3000,20 @@ func (s SqlChannelStore) autocompleteInTeamForSearchDirectMessages(userId string
%v
) AS OtherUsers ON OtherUsers.ChannelId = C.Id
WHERE
C.Type = 'D'
C.Type = :ChannelType
AND CM.UserId = :UserId
LIMIT 50`
var channels model.ChannelList
if likeClause, likeTerm := s.buildLIKEClause(term, "IU.Username, IU.Nickname"); likeClause == "" {
if _, err := s.GetReplica().Select(&channels, fmt.Sprintf(queryFormat, ""), map[string]interface{}{"UserId": userId}); err != nil {
if _, err := s.GetReplica().Select(&channels, fmt.Sprintf(queryFormat, ""), map[string]interface{}{"UserId": userId, "ChannelType": model.ChannelTypeDirect}); err != nil {
return nil, errors.Wrapf(err, "failed to find Channels with term='%s'", term)
}
} else {
query := fmt.Sprintf(queryFormat, "AND "+likeClause)
if _, err := s.GetReplica().Select(&channels, query, map[string]interface{}{"UserId": userId, "LikeTerm": likeTerm}); err != nil {
if _, err := s.GetReplica().Select(&channels, query, map[string]interface{}{"UserId": userId, "LikeTerm": likeTerm, "ChannelType": model.ChannelTypeDirect}); err != nil {
return nil, errors.Wrapf(err, "failed to find Channels with term='%s'", term)
}
}
@@ -3057,12 +3059,13 @@ func (s SqlChannelStore) SearchArchivedInTeam(teamId string, term string, userId
c.TeamId = :TeamId
SEARCH_CLAUSE
AND c.DeleteAt != 0
AND c.Type != 'P'
AND c.Type != :ChannelType
ORDER BY c.DisplayName
LIMIT 100
`, term, map[string]interface{}{
"TeamId": teamId,
"UserId": userId,
"TeamId": teamId,
"UserId": userId,
"ChannelType": model.ChannelTypePrivate,
})
privateChannels, privateErr := s.performSearch(`
@@ -3076,13 +3079,14 @@ func (s SqlChannelStore) SearchArchivedInTeam(teamId string, term string, userId
c.TeamId = :TeamId
SEARCH_CLAUSE
AND c.DeleteAt != 0
AND c.Type = 'P'
AND c.Type = :ChannelType
AND c.Id IN (SELECT ChannelId FROM ChannelMembers WHERE UserId = :UserId)
ORDER BY c.DisplayName
LIMIT 100
`, term, map[string]interface{}{
"TeamId": teamId,
"UserId": userId,
"TeamId": teamId,
"UserId": userId,
"ChannelType": model.ChannelTypePrivate,
})
outputErr := publicErr
@@ -3422,7 +3426,7 @@ func (s SqlChannelStore) getSearchGroupChannelsQuery(userId, term string, isPost
JOIN
Users u on u.Id = cm.UserId
WHERE
c.Type = 'G'
c.Type = :ChannelType
AND
u.Id = :UserId
GROUP BY
@@ -3454,7 +3458,7 @@ func (s SqlChannelStore) getSearchGroupChannelsQuery(userId, term string, isPost
JOIN
Users u on u.Id = cm.UserId
WHERE
c.Type = 'G'
c.Type = :ChannelType
AND
u.Id = :UserId
GROUP BY
@@ -3473,7 +3477,7 @@ func (s SqlChannelStore) getSearchGroupChannelsQuery(userId, term string, isPost
}
var likeClauses []string
args := map[string]interface{}{"UserId": userId}
args := map[string]interface{}{"UserId": userId, "ChannelType": model.ChannelTypeGroup}
terms := strings.Split(strings.ToLower(strings.Trim(term, " ")), " ")
for idx, term := range terms {
@@ -3748,11 +3752,11 @@ func (s SqlChannelStore) GetAllChannelsForExportAfter(limit int, afterId string)
Schemes ON Channels.SchemeId = Schemes.Id
WHERE
Channels.Id > ?
AND Channels.Type IN ('O', 'P')
AND Channels.Type IN (?, ?)
ORDER BY
Id
LIMIT ?`,
afterId, limit); err != nil {
afterId, model.ChannelTypeOpen, model.ChannelTypePrivate, limit); err != nil {
return nil, errors.Wrap(err, "failed to find Channels for export")
}
@@ -3800,7 +3804,7 @@ func (s SqlChannelStore) GetAllDirectChannelsForExportAfter(limit int, afterId s
Where(sq.And{
sq.Gt{"Channels.Id": afterId},
sq.Eq{"Channels.DeleteAt": int(0)},
sq.Eq{"Channels.Type": []string{"D", "G"}},
sq.Eq{"Channels.Type": []model.ChannelType{model.ChannelTypeDirect, model.ChannelTypeGroup}},
}).
OrderBy("Channels.Id").
Limit(uint64(limit))

Просмотреть файл

@@ -157,7 +157,7 @@ func (s SqlComplianceStore) ComplianceExport(job *model.Compliance, cursor model
if cursor.LastChannelsQueryPostCreateAt == 0 {
cursor.LastChannelsQueryPostCreateAt = job.StartAt
}
//append the named parameters of SQL query in the correct order to argsChannelsQuery
// append the named parameters of SQL query in the correct order to argsChannelsQuery
argsChannelsQuery = append(argsChannelsQuery, cursor.LastChannelsQueryPostCreateAt, cursor.LastChannelsQueryPostCreateAt, cursor.LastChannelsQueryPostID, job.EndAt)
argsChannelsQuery = append(argsChannelsQuery, argsEmails...)
argsChannelsQuery = append(argsChannelsQuery, argsKeywords...)
@@ -222,7 +222,7 @@ func (s SqlComplianceStore) ComplianceExport(job *model.Compliance, cursor model
if cursor.LastDirectMessagesQueryPostCreateAt == 0 {
cursor.LastDirectMessagesQueryPostCreateAt = job.StartAt
}
//append the named parameters of SQL query in the correct order to argsDirectMessagesQuery
// append the named parameters of SQL query in the correct order to argsDirectMessagesQuery
argsDirectMessagesQuery = append(argsDirectMessagesQuery, cursor.LastDirectMessagesQueryPostCreateAt, cursor.LastDirectMessagesQueryPostCreateAt, cursor.LastDirectMessagesQueryPostID, job.EndAt)
argsDirectMessagesQuery = append(argsDirectMessagesQuery, argsEmails...)
argsDirectMessagesQuery = append(argsDirectMessagesQuery, argsKeywords...)
@@ -285,7 +285,7 @@ func (s SqlComplianceStore) ComplianceExport(job *model.Compliance, cursor model
func (s SqlComplianceStore) MessageExport(cursor model.MessageExportCursor, limit int) ([]*model.MessageExport, model.MessageExportCursor, error) {
var args []interface{}
args = append(args, cursor.LastPostUpdateAt, cursor.LastPostUpdateAt, cursor.LastPostId, limit)
args = append(args, model.ChannelTypeDirect, model.ChannelTypeGroup, cursor.LastPostUpdateAt, cursor.LastPostUpdateAt, cursor.LastPostId, limit)
query :=
`SELECT
Posts.Id AS PostId,
@@ -303,8 +303,8 @@ func (s SqlComplianceStore) MessageExport(cursor model.MessageExportCursor, limi
Teams.DisplayName AS TeamDisplayName,
Channels.Id AS ChannelId,
CASE
WHEN Channels.Type = 'D' THEN 'Direct Message'
WHEN Channels.Type = 'G' THEN 'Group Message'
WHEN Channels.Type = ? THEN 'Direct Message'
WHEN Channels.Type = ? THEN 'Group Message'
ELSE Channels.DisplayName
END AS ChannelDisplayName,
Channels.Name AS ChannelName,

Просмотреть файл

@@ -2369,7 +2369,7 @@ func (s *SqlPostStore) GetDirectPostParentsForExportAfter(limit int, afterId str
sq.Eq{"p.DeleteAt": 0},
sq.Eq{"Channels.DeleteAt": 0},
sq.Eq{"Users.DeleteAt": 0},
sq.Eq{"Channels.Type": []string{"D", "G"}},
sq.Eq{"Channels.Type": []model.ChannelType{model.ChannelTypeDirect, model.ChannelTypeGroup}},
}).
OrderBy("p.Id").
Limit(uint64(limit))

Просмотреть файл

@@ -1353,7 +1353,7 @@ func (us SqlUserStore) AnalyticsActiveCountForPeriod(startTime int64, endTime in
func (us SqlUserStore) GetUnreadCount(userId string) (int64, error) {
query := `
SELECT SUM(CASE WHEN c.Type = 'D' THEN (c.TotalMsgCount - cm.MsgCount) ELSE cm.MentionCount END)
SELECT SUM(CASE WHEN c.Type = ? THEN (c.TotalMsgCount - cm.MsgCount) ELSE cm.MentionCount END)
FROM Channels c
INNER JOIN ChannelMembers cm
ON cm.ChannelId = c.Id
@@ -1362,7 +1362,7 @@ func (us SqlUserStore) GetUnreadCount(userId string) (int64, error) {
`
var count int64
err := us.GetReplicaX().Get(&count, query, userId)
err := us.GetReplicaX().Get(&count, query, model.ChannelTypeDirect, userId)
if err != nil {
return count, errors.Wrapf(err, "failed to count unread Channels for userId=%s", userId)
}
@@ -1372,7 +1372,7 @@ func (us SqlUserStore) GetUnreadCount(userId string) (int64, error) {
func (us SqlUserStore) GetUnreadCountForChannel(userId string, channelId string) (int64, error) {
var count int64
err := us.GetReplicaX().Get(&count, "SELECT SUM(CASE WHEN c.Type = 'D' THEN (c.TotalMsgCount - cm.MsgCount) ELSE cm.MentionCount END) FROM Channels c INNER JOIN ChannelMembers cm ON c.Id = cm.ChannelId AND cm.ChannelId = ? AND cm.UserId = ?", channelId, userId)
err := us.GetReplicaX().Get(&count, "SELECT SUM(CASE WHEN c.Type = ? THEN (c.TotalMsgCount - cm.MsgCount) ELSE cm.MentionCount END) FROM Channels c INNER JOIN ChannelMembers cm ON c.Id = cm.ChannelId AND cm.ChannelId = ? AND cm.UserId = ?", model.ChannelTypeDirect, channelId, userId)
if err != nil {
return 0, errors.Wrapf(err, "failed to get unread count for channelId=%s and userId=%s", channelId, userId)
}
@@ -1733,7 +1733,7 @@ func (us SqlUserStore) GetUsersBatchForIndexing(startTime, endTime int64, limit
`).
From("ChannelMembers cm").
Join("Channels c ON cm.ChannelId = c.Id").
Where(sq.Eq{"c.Type": "O", "cm.UserId": userIds}).
Where(sq.Eq{"c.Type": model.ChannelTypeOpen, "cm.UserId": userIds}).
ToSql()
_, err = us.GetSearchReplica().Select(&channelMembers, channelMembersQuery, args...)
if err != nil {

Просмотреть файл

@@ -244,7 +244,7 @@ type ChannelStore interface {
GetMembersByIds(channelID string, userIds []string) (model.ChannelMembers, error)
GetMembersByChannelIds(channelIds []string, userID string) (model.ChannelMembers, error)
GetMembersInfoByChannelIds(channelIDs []string) (map[string][]*model.User, error)
AnalyticsDeletedTypeCount(teamID string, channelType string) (int64, error)
AnalyticsDeletedTypeCount(teamID string, channelType model.ChannelType) (int64, error)
GetChannelUnread(channelID, userID string) (*model.ChannelUnread, error)
ClearCaches()
GetChannelsByScheme(schemeID string, offset int, limit int) (model.ChannelList, error)

Просмотреть файл

@@ -6626,15 +6626,15 @@ func testChannelStoreAnalyticsDeletedTypeCount(t *testing.T, ss store.Store) {
}()
var openStartCount int64
openStartCount, nErr = ss.Channel().AnalyticsDeletedTypeCount("", "O")
openStartCount, nErr = ss.Channel().AnalyticsDeletedTypeCount("", model.ChannelTypeOpen)
require.NoError(t, nErr, nErr)
var privateStartCount int64
privateStartCount, nErr = ss.Channel().AnalyticsDeletedTypeCount("", "P")
privateStartCount, nErr = ss.Channel().AnalyticsDeletedTypeCount("", model.ChannelTypePrivate)
require.NoError(t, nErr, nErr)
var directStartCount int64
directStartCount, nErr = ss.Channel().AnalyticsDeletedTypeCount("", "D")
directStartCount, nErr = ss.Channel().AnalyticsDeletedTypeCount("", model.ChannelTypeDirect)
require.NoError(t, nErr, nErr)
nErr = ss.Channel().Delete(o1.Id, model.GetMillis())
@@ -6648,15 +6648,15 @@ func testChannelStoreAnalyticsDeletedTypeCount(t *testing.T, ss store.Store) {
var count int64
count, nErr = ss.Channel().AnalyticsDeletedTypeCount("", "O")
count, nErr = ss.Channel().AnalyticsDeletedTypeCount("", model.ChannelTypeOpen)
require.NoError(t, err, nErr)
assert.Equal(t, openStartCount+2, count, "Wrong open channel deleted count.")
count, nErr = ss.Channel().AnalyticsDeletedTypeCount("", "P")
count, nErr = ss.Channel().AnalyticsDeletedTypeCount("", model.ChannelTypePrivate)
require.NoError(t, nErr, nErr)
assert.Equal(t, privateStartCount+1, count, "Wrong private channel deleted count.")
count, nErr = ss.Channel().AnalyticsDeletedTypeCount("", "D")
count, nErr = ss.Channel().AnalyticsDeletedTypeCount("", model.ChannelTypeDirect)
require.NoError(t, nErr, nErr)
assert.Equal(t, directStartCount+1, count, "Wrong direct channel deleted count.")
}

Просмотреть файл

@@ -19,18 +19,18 @@ type ChannelStore struct {
}
// AnalyticsDeletedTypeCount provides a mock function with given fields: teamID, channelType
func (_m *ChannelStore) AnalyticsDeletedTypeCount(teamID string, channelType string) (int64, error) {
func (_m *ChannelStore) AnalyticsDeletedTypeCount(teamID string, channelType model.ChannelType) (int64, error) {
ret := _m.Called(teamID, channelType)
var r0 int64
if rf, ok := ret.Get(0).(func(string, string) int64); ok {
if rf, ok := ret.Get(0).(func(string, model.ChannelType) int64); ok {
r0 = rf(teamID, channelType)
} else {
r0 = ret.Get(0).(int64)
}
var r1 error
if rf, ok := ret.Get(1).(func(string, string) error); ok {
if rf, ok := ret.Get(1).(func(string, model.ChannelType) error); ok {
r1 = rf(teamID, channelType)
} else {
r1 = ret.Error(1)

Просмотреть файл

@@ -518,7 +518,7 @@ func (s *TimerLayerBotStore) Update(bot *model.Bot) (*model.Bot, error) {
return result, err
}
func (s *TimerLayerChannelStore) AnalyticsDeletedTypeCount(teamID string, channelType string) (int64, error) {
func (s *TimerLayerChannelStore) AnalyticsDeletedTypeCount(teamID string, channelType model.ChannelType) (int64, error) {
start := timemodule.Now()
result, err := s.ChannelStore.AnalyticsDeletedTypeCount(teamID, channelType)