diff options
author | Christopher Speller <crspeller@gmail.com> | 2016-02-03 08:50:25 -0500 |
---|---|---|
committer | Christopher Speller <crspeller@gmail.com> | 2016-02-03 08:50:25 -0500 |
commit | d479b08c997d3216938a3e92c3634a8b5afdb841 (patch) | |
tree | 59e23ddb3feea7f10c16b535892b9c44952e0779 /store/sql_webhook_store.go | |
parent | 0571953755bb96b3d1c15279e2fb429a3ec993a5 (diff) | |
parent | 9517690577111242f12f03eb27ee32d11e9d71a6 (diff) | |
download | chat-d479b08c997d3216938a3e92c3634a8b5afdb841.tar.gz chat-d479b08c997d3216938a3e92c3634a8b5afdb841.tar.bz2 chat-d479b08c997d3216938a3e92c3634a8b5afdb841.zip |
Merge pull request #2045 from mattermost/plt-1849
PLT-1849 Added extra system-wide statistics for EE
Diffstat (limited to 'store/sql_webhook_store.go')
-rw-r--r-- | store/sql_webhook_store.go | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/store/sql_webhook_store.go b/store/sql_webhook_store.go index cdfb949f5..5298b0b94 100644 --- a/store/sql_webhook_store.go +++ b/store/sql_webhook_store.go @@ -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 +} |