summaryrefslogtreecommitdiffstats
path: root/store/sql_webhook_store.go
diff options
context:
space:
mode:
authorJoramWilander <jwawilander@gmail.com>2016-02-02 08:41:02 -0500
committerJoramWilander <jwawilander@gmail.com>2016-02-02 08:41:02 -0500
commit3d03bdf2f1af5385c2150544977fbba89650b1ee (patch)
tree77936a01b35e91bfb4126f5a9f4c5a4660130ae4 /store/sql_webhook_store.go
parentf28486c4553f7f4bccf7bf69153c2f12699705f9 (diff)
downloadchat-3d03bdf2f1af5385c2150544977fbba89650b1ee.tar.gz
chat-3d03bdf2f1af5385c2150544977fbba89650b1ee.tar.bz2
chat-3d03bdf2f1af5385c2150544977fbba89650b1ee.zip
Added extra system-wide statistics for EE
Diffstat (limited to 'store/sql_webhook_store.go')
-rw-r--r--store/sql_webhook_store.go62
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
+}