summaryrefslogtreecommitdiffstats
path: root/store/sql_session_store.go
diff options
context:
space:
mode:
authorJoramWilander <jwawilander@gmail.com>2016-02-25 12:32:46 -0500
committerJoramWilander <jwawilander@gmail.com>2016-03-01 10:46:30 -0500
commit8239c68cf323e4bb20007d2b456336becead273d (patch)
tree3422ed0946afafa47d6649e09f6f09ee71692363 /store/sql_session_store.go
parent8aa4e28932ec43090ca6b481929fafbe0119a660 (diff)
downloadchat-8239c68cf323e4bb20007d2b456336becead273d.tar.gz
chat-8239c68cf323e4bb20007d2b456336becead273d.tar.bz2
chat-8239c68cf323e4bb20007d2b456336becead273d.zip
Refactor and modularize analytics on the client
Diffstat (limited to 'store/sql_session_store.go')
-rw-r--r--store/sql_session_store.go29
1 files changed, 29 insertions, 0 deletions
diff --git a/store/sql_session_store.go b/store/sql_session_store.go
index 8dccc0770..6fe71db17 100644
--- a/store/sql_session_store.go
+++ b/store/sql_session_store.go
@@ -255,3 +255,32 @@ func (me SqlSessionStore) UpdateDeviceId(id, deviceId string) StoreChannel {
return storeChannel
}
+
+func (me SqlSessionStore) AnalyticsSessionCount(teamId string) StoreChannel {
+ storeChannel := make(StoreChannel)
+
+ go func() {
+ result := StoreResult{}
+
+ query :=
+ `SELECT
+ COUNT(*)
+ FROM
+ Sessions`
+
+ if len(teamId) > 0 {
+ query += " WHERE TeamId = :TeamId"
+ }
+
+ if c, err := me.GetReplica().SelectInt(query, map[string]interface{}{"TeamId": teamId}); err != nil {
+ result.Err = model.NewLocAppError("SqlSessionStore.AnalyticsSessionCount", "store.sql_session.analytics_session_count.app_error", nil, err.Error())
+ } else {
+ result.Data = c
+ }
+
+ storeChannel <- result
+ close(storeChannel)
+ }()
+
+ return storeChannel
+}