From 52403ca17eaf2e469c5978a962195c2f886fb22e Mon Sep 17 00:00:00 2001
From: bergquist <carl.bergquist@gmail.com>
Date: Mon, 25 Jan 2016 21:39:04 +0100
Subject: [PATCH] feat(playlist): add usage statisics

---
 pkg/metrics/report_usage.go    | 1 +
 pkg/models/stats.go            | 1 +
 pkg/services/sqlstore/stats.go | 8 +++++++-
 3 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/pkg/metrics/report_usage.go b/pkg/metrics/report_usage.go
index abda18d12b7..c5c2afed7f7 100644
--- a/pkg/metrics/report_usage.go
+++ b/pkg/metrics/report_usage.go
@@ -55,6 +55,7 @@ func sendUsageStats() {
 	metrics["stats.dashboards.count"] = statsQuery.Result.DashboardCount
 	metrics["stats.users.count"] = statsQuery.Result.UserCount
 	metrics["stats.orgs.count"] = statsQuery.Result.OrgCount
+	metrics["stats.playlist.count"] = statsQuery.Result.PlaylistCount
 
 	dsStats := m.GetDataSourceStatsQuery{}
 	if err := bus.Dispatch(&dsStats); err != nil {
diff --git a/pkg/models/stats.go b/pkg/models/stats.go
index 6a060137ac7..30c09deb768 100644
--- a/pkg/models/stats.go
+++ b/pkg/models/stats.go
@@ -4,6 +4,7 @@ type SystemStats struct {
 	DashboardCount int
 	UserCount      int
 	OrgCount       int
+	PlaylistCount  int
 }
 
 type DataSourceStats struct {
diff --git a/pkg/services/sqlstore/stats.go b/pkg/services/sqlstore/stats.go
index 044aa185f19..203534b3b93 100644
--- a/pkg/services/sqlstore/stats.go
+++ b/pkg/services/sqlstore/stats.go
@@ -1,6 +1,8 @@
 package sqlstore
 
 import (
+	"fmt"
+
 	"github.com/grafana/grafana/pkg/bus"
 	m "github.com/grafana/grafana/pkg/models"
 )
@@ -34,7 +36,11 @@ func GetSystemStats(query *m.GetSystemStatsQuery) error {
       (
         SELECT COUNT(*)
         FROM ` + dialect.Quote("dashboard") + `
-      ) AS dashboard_count
+      ) AS dashboard_count,
+      (
+        SELECT COUNT(*)
+        FROM ` + dialect.Quote("playlist") + `
+      ) AS playlist_count
 			`
 
 	var stats m.SystemStats