Added extra system-wide statistics for EE
Этот коммит содержится в:
@@ -940,7 +940,7 @@ func (s SqlPostStore) AnalyticsPostCountsByDay(teamId string) StoreChannel {
|
||||
return storeChannel
|
||||
}
|
||||
|
||||
func (s SqlPostStore) AnalyticsPostCount(teamId string) StoreChannel {
|
||||
func (s SqlPostStore) AnalyticsPostCount(teamId string, mustHaveFile bool, mustHaveHashtag bool) StoreChannel {
|
||||
storeChannel := make(StoreChannel)
|
||||
|
||||
go func() {
|
||||
@@ -959,8 +959,15 @@ func (s SqlPostStore) AnalyticsPostCount(teamId string) StoreChannel {
|
||||
query += " AND Channels.TeamId = :TeamId"
|
||||
}
|
||||
|
||||
v, err := s.GetReplica().SelectInt(query, map[string]interface{}{"TeamId": teamId})
|
||||
if err != nil {
|
||||
if mustHaveFile {
|
||||
query += " AND Posts.Filenames != '[]'"
|
||||
}
|
||||
|
||||
if mustHaveHashtag {
|
||||
query += " AND Posts.Hashtags != ''"
|
||||
}
|
||||
|
||||
if v, err := s.GetReplica().SelectInt(query, map[string]interface{}{"TeamId": teamId}); err != nil {
|
||||
result.Err = model.NewLocAppError("SqlPostStore.AnalyticsPostCount", "store.sql_post.analytics_posts_count.app_error", nil, err.Error())
|
||||
} else {
|
||||
result.Data = v
|
||||
|
||||
@@ -887,7 +887,7 @@ func TestPostCountsByDay(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
if r1 := <-store.Post().AnalyticsPostCount(t1.Id); r1.Err != nil {
|
||||
if r1 := <-store.Post().AnalyticsPostCount(t1.Id, false, false); r1.Err != nil {
|
||||
t.Fatal(r1.Err)
|
||||
} else {
|
||||
if r1.Data.(int64) != 4 {
|
||||
|
||||
@@ -350,3 +350,65 @@ func (s SqlWebhookStore) UpdateOutgoing(hook *model.OutgoingWebhook) StoreChanne
|
||||
|
||||
return storeChannel
|
||||
}
|
||||
|
||||
func (s SqlWebhookStore) AnalyticsIncomingCount(teamId string) StoreChannel {
|
||||
storeChannel := make(StoreChannel)
|
||||
|
||||
go func() {
|
||||
result := StoreResult{}
|
||||
|
||||
query :=
|
||||
`SELECT
|
||||
COUNT(*)
|
||||
FROM
|
||||
IncomingWebhooks
|
||||
WHERE
|
||||
DeleteAt = 0`
|
||||
|
||||
if len(teamId) > 0 {
|
||||
query += " AND TeamId = :TeamId"
|
||||
}
|
||||
|
||||
if v, err := s.GetReplica().SelectInt(query, map[string]interface{}{"TeamId": teamId}); err != nil {
|
||||
result.Err = model.NewLocAppError("SqlWebhookStore.AnalyticsIncomingCount", "store.sql_webhooks.analytics_incoming_count.app_error", nil, "team_id="+teamId+", err="+err.Error())
|
||||
} else {
|
||||
result.Data = v
|
||||
}
|
||||
|
||||
storeChannel <- result
|
||||
close(storeChannel)
|
||||
}()
|
||||
|
||||
return storeChannel
|
||||
}
|
||||
|
||||
func (s SqlWebhookStore) AnalyticsOutgoingCount(teamId string) StoreChannel {
|
||||
storeChannel := make(StoreChannel)
|
||||
|
||||
go func() {
|
||||
result := StoreResult{}
|
||||
|
||||
query :=
|
||||
`SELECT
|
||||
COUNT(*)
|
||||
FROM
|
||||
OutgoingWebhooks
|
||||
WHERE
|
||||
DeleteAt = 0`
|
||||
|
||||
if len(teamId) > 0 {
|
||||
query += " AND TeamId = :TeamId"
|
||||
}
|
||||
|
||||
if v, err := s.GetReplica().SelectInt(query, map[string]interface{}{"TeamId": teamId}); err != nil {
|
||||
result.Err = model.NewLocAppError("SqlWebhookStore.AnalyticsOutgoingCount", "store.sql_webhooks.analytics_outgoing_count.app_error", nil, "team_id="+teamId+", err="+err.Error())
|
||||
} else {
|
||||
result.Data = v
|
||||
}
|
||||
|
||||
storeChannel <- result
|
||||
close(storeChannel)
|
||||
}()
|
||||
|
||||
return storeChannel
|
||||
}
|
||||
|
||||
@@ -332,3 +332,42 @@ func TestWebhookStoreUpdateOutgoing(t *testing.T) {
|
||||
t.Fatal(r2.Err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestWebhookStoreCountIncoming(t *testing.T) {
|
||||
Setup()
|
||||
|
||||
o1 := &model.IncomingWebhook{}
|
||||
o1.ChannelId = model.NewId()
|
||||
o1.UserId = model.NewId()
|
||||
o1.TeamId = model.NewId()
|
||||
|
||||
o1 = (<-store.Webhook().SaveIncoming(o1)).Data.(*model.IncomingWebhook)
|
||||
|
||||
if r := <-store.Webhook().AnalyticsIncomingCount(""); r.Err != nil {
|
||||
t.Fatal(r.Err)
|
||||
} else {
|
||||
if r.Data.(int64) == 0 {
|
||||
t.Fatal("should have at least 1 incoming hook")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestWebhookStoreCountOutgoing(t *testing.T) {
|
||||
Setup()
|
||||
|
||||
o1 := &model.OutgoingWebhook{}
|
||||
o1.ChannelId = model.NewId()
|
||||
o1.CreatorId = model.NewId()
|
||||
o1.TeamId = model.NewId()
|
||||
o1.CallbackURLs = []string{"http://nowhere.com/"}
|
||||
|
||||
o1 = (<-store.Webhook().SaveOutgoing(o1)).Data.(*model.OutgoingWebhook)
|
||||
|
||||
if r := <-store.Webhook().AnalyticsOutgoingCount(""); r.Err != nil {
|
||||
t.Fatal(r.Err)
|
||||
} else {
|
||||
if r.Data.(int64) == 0 {
|
||||
t.Fatal("should have at least 1 outgoing hook")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -100,7 +100,7 @@ type PostStore interface {
|
||||
GetForExport(channelId string) StoreChannel
|
||||
AnalyticsUserCountsWithPostsByDay(teamId string) StoreChannel
|
||||
AnalyticsPostCountsByDay(teamId string) StoreChannel
|
||||
AnalyticsPostCount(teamId string) StoreChannel
|
||||
AnalyticsPostCount(teamId string, mustHaveFile bool, mustHaveHashtag bool) StoreChannel
|
||||
}
|
||||
|
||||
type UserStore interface {
|
||||
@@ -182,6 +182,8 @@ type WebhookStore interface {
|
||||
DeleteOutgoing(webhookId string, time int64) StoreChannel
|
||||
PermanentDeleteOutgoingByUser(userId string) StoreChannel
|
||||
UpdateOutgoing(hook *model.OutgoingWebhook) StoreChannel
|
||||
AnalyticsIncomingCount(teamId string) StoreChannel
|
||||
AnalyticsOutgoingCount(teamId string) StoreChannel
|
||||
}
|
||||
|
||||
type PreferenceStore interface {
|
||||
|
||||
Ссылка в новой задаче
Block a user