Migrate Channel.AnalyticsTypeCount to Sync by default (#11097)
* Migrate Channel.AnalyticsTypeCount to Sync by default * Fixing tests
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
b13c5eabff
Коммит
7c4cc21475
@@ -44,8 +44,18 @@ func (a *App) GetAnalytics(name string, teamId string) (model.AnalyticsRows, *mo
|
||||
rows[9] = &model.AnalyticsRow{Name: "monthly_active_users", Value: 0}
|
||||
rows[10] = &model.AnalyticsRow{Name: "inactive_user_count", Value: 0}
|
||||
|
||||
openChan := a.Srv.Store.Channel().AnalyticsTypeCount(teamId, model.CHANNEL_OPEN)
|
||||
privateChan := a.Srv.Store.Channel().AnalyticsTypeCount(teamId, model.CHANNEL_PRIVATE)
|
||||
openChan := make(chan store.StoreResult, 1)
|
||||
privateChan := make(chan store.StoreResult, 1)
|
||||
go func() {
|
||||
count, err := a.Srv.Store.Channel().AnalyticsTypeCount(teamId, model.CHANNEL_OPEN)
|
||||
openChan <- store.StoreResult{Data: count, Err: err}
|
||||
close(openChan)
|
||||
}()
|
||||
go func() {
|
||||
count, err := a.Srv.Store.Channel().AnalyticsTypeCount(teamId, model.CHANNEL_PRIVATE)
|
||||
privateChan <- store.StoreResult{Data: count, Err: err}
|
||||
close(privateChan)
|
||||
}()
|
||||
|
||||
var userChan store.StoreChannel
|
||||
var userInactiveChan store.StoreChannel
|
||||
|
||||
@@ -171,16 +171,16 @@ func (a *App) trackActivity() {
|
||||
mlog.Error(err.Error())
|
||||
}
|
||||
|
||||
if ucc := <-a.Srv.Store.Channel().AnalyticsTypeCount("", "O"); ucc.Err == nil {
|
||||
publicChannelCount = ucc.Data.(int64)
|
||||
if ucc, err := a.Srv.Store.Channel().AnalyticsTypeCount("", "O"); err == nil {
|
||||
publicChannelCount = ucc
|
||||
}
|
||||
|
||||
if pcc := <-a.Srv.Store.Channel().AnalyticsTypeCount("", "P"); pcc.Err == nil {
|
||||
privateChannelCount = pcc.Data.(int64)
|
||||
if pcc, err := a.Srv.Store.Channel().AnalyticsTypeCount("", "P"); err == nil {
|
||||
privateChannelCount = pcc
|
||||
}
|
||||
|
||||
if dcc := <-a.Srv.Store.Channel().AnalyticsTypeCount("", "D"); dcc.Err == nil {
|
||||
directChannelCount = dcc.Data.(int64)
|
||||
if dcc, err := a.Srv.Store.Channel().AnalyticsTypeCount("", "D"); err == nil {
|
||||
directChannelCount = dcc
|
||||
}
|
||||
|
||||
if duccr := <-a.Srv.Store.Channel().AnalyticsDeletedTypeCount("", "O"); duccr.Err == nil {
|
||||
|
||||
@@ -488,9 +488,9 @@ func (me *TestHelper) CheckTeamCount(t *testing.T, expected int64) {
|
||||
}
|
||||
|
||||
func (me *TestHelper) CheckChannelsCount(t *testing.T, expected int64) {
|
||||
if r := <-me.App.Srv.Store.Channel().AnalyticsTypeCount("", model.CHANNEL_OPEN); r.Err == nil {
|
||||
if r.Data.(int64) != expected {
|
||||
t.Fatalf("Unexpected number of channels. Expected: %v, found: %v", expected, r.Data.(int64))
|
||||
if count, err := me.App.Srv.Store.Channel().AnalyticsTypeCount("", model.CHANNEL_OPEN); err == nil {
|
||||
if count != expected {
|
||||
t.Fatalf("Unexpected number of channels. Expected: %v, found: %v", expected, count)
|
||||
}
|
||||
} else {
|
||||
t.Fatalf("Failed to get channel count.")
|
||||
|
||||
@@ -679,12 +679,8 @@ func TestImportImportChannel(t *testing.T) {
|
||||
}
|
||||
|
||||
// Check how many channels are in the database.
|
||||
var channelCount int64
|
||||
if r := <-th.App.Srv.Store.Channel().AnalyticsTypeCount("", model.CHANNEL_OPEN); r.Err == nil {
|
||||
channelCount = r.Data.(int64)
|
||||
} else {
|
||||
t.Fatalf("Failed to get team count.")
|
||||
}
|
||||
channelCount, err := th.App.Srv.Store.Channel().AnalyticsTypeCount("", model.CHANNEL_OPEN)
|
||||
require.Nil(t, err, "Failed to get team count.")
|
||||
|
||||
// Do an invalid channel in dry-run mode.
|
||||
data := ChannelImportData{
|
||||
@@ -2173,19 +2169,11 @@ func TestImportImportDirectChannel(t *testing.T) {
|
||||
defer th.TearDown()
|
||||
|
||||
// Check how many channels are in the database.
|
||||
var directChannelCount int64
|
||||
if r := <-th.App.Srv.Store.Channel().AnalyticsTypeCount("", model.CHANNEL_DIRECT); r.Err == nil {
|
||||
directChannelCount = r.Data.(int64)
|
||||
} else {
|
||||
t.Fatalf("Failed to get direct channel count.")
|
||||
}
|
||||
directChannelCount, err := th.App.Srv.Store.Channel().AnalyticsTypeCount("", model.CHANNEL_DIRECT)
|
||||
require.Nil(t, err, "Failed to get direct channel count.")
|
||||
|
||||
var groupChannelCount int64
|
||||
if r := <-th.App.Srv.Store.Channel().AnalyticsTypeCount("", model.CHANNEL_GROUP); r.Err == nil {
|
||||
groupChannelCount = r.Data.(int64)
|
||||
} else {
|
||||
t.Fatalf("Failed to get group channel count.")
|
||||
}
|
||||
groupChannelCount, err := th.App.Srv.Store.Channel().AnalyticsTypeCount("", model.CHANNEL_GROUP)
|
||||
require.Nil(t, err, "Failed to get group channel count.")
|
||||
|
||||
// Do an invalid channel in dry-run mode.
|
||||
data := DirectChannelImportData{
|
||||
@@ -2194,7 +2182,7 @@ func TestImportImportDirectChannel(t *testing.T) {
|
||||
},
|
||||
Header: ptrStr("Channel Header"),
|
||||
}
|
||||
err := th.App.ImportDirectChannel(&data, true)
|
||||
err = th.App.ImportDirectChannel(&data, true)
|
||||
require.NotNil(t, err)
|
||||
|
||||
// Check that no more channels are in the DB.
|
||||
|
||||
@@ -92,8 +92,7 @@ func AssertAllPostsCount(t *testing.T, a *App, initialCount int64, change int64,
|
||||
}
|
||||
|
||||
func AssertChannelCount(t *testing.T, a *App, channelType string, expectedCount int64) {
|
||||
if r := <-a.Srv.Store.Channel().AnalyticsTypeCount("", channelType); r.Err == nil {
|
||||
count := r.Data.(int64)
|
||||
if count, err := a.Srv.Store.Channel().AnalyticsTypeCount("", channelType); err == nil {
|
||||
if count != expectedCount {
|
||||
debug.PrintStack()
|
||||
t.Fatalf("Channel count of type: %v. Expected: %v, Got: %v", channelType, expectedCount, count)
|
||||
|
||||
Ссылка в новой задаче
Block a user