Przeglądaj źródła

feat(stats): add alerts to global admin stats

bergquist 9 lat temu
rodzic
commit
a87fd11f26

+ 1 - 0
pkg/models/stats.go

@@ -30,6 +30,7 @@ type AdminStats struct {
 	DataSourceCount int `json:"data_source_count"`
 	PlaylistCount   int `json:"playlist_count"`
 	StarredDbCount  int `json:"starred_db_count"`
+	AlertCount      int `json:"alert_count"`
 }
 
 type GetAdminStatsQuery struct {

+ 5 - 1
pkg/services/sqlstore/stats.go

@@ -89,7 +89,11 @@ func GetAdminStats(query *m.GetAdminStatsQuery) error {
       (
         SELECT COUNT(DISTINCT ` + dialect.Quote("dashboard_id") + ` )
         FROM ` + dialect.Quote("star") + `
-      ) AS starred_db_count
+      ) AS starred_db_count,
+      (
+        SELECT COUNT(*)
+        FROM ` + dialect.Quote("alert") + `
+      ) AS alert_count
       `
 
 	var stats m.AdminStats

+ 4 - 0
public/app/features/admin/partials/stats.html

@@ -46,6 +46,10 @@
 				<td>Total starred dashboards</td>
 				<td>{{ctrl.stats.starred_db_count}}</td>
 			</tr>
+      <tr>
+				<td>Total alerts</td>
+				<td>{{ctrl.stats.alert_count}}</td>
+			</tr>
 		</tbody>
 	</table>
 </div>