From 1ab11540104c0036ef54527722f9da70a35a66c7 Mon Sep 17 00:00:00 2001 From: utkarshcmu Date: Tue, 19 Jan 2016 04:09:57 -0800 Subject: [PATCH] Optimized backend queries --- pkg/api/api.go | 3 +-- pkg/api/index.go | 2 +- pkg/services/sqlstore/dashboard_snapshot.go | 3 +-- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/pkg/api/api.go b/pkg/api/api.go index 4f4a1ddd72f..c42bb376df2 100644 --- a/pkg/api/api.go +++ b/pkg/api/api.go @@ -69,7 +69,6 @@ func Register(r *macaron.Macaron) { // dashboard snapshots r.Get("/dashboard/snapshot/*", Index) - r.Get("/dashboard/snapshots/", reqSignedIn, Index) // api for dashboard snapshots r.Post("/api/snapshots/", bind(m.CreateDashboardSnapshotCommand{}), CreateDashboardSnapshot) @@ -184,7 +183,7 @@ func Register(r *macaron.Macaron) { r.Get("/tags", GetDashboardTags) }) - // dashboard snapshots + // Dashboard snapshots r.Group("/dashboard/snapshots", func() { r.Get("/", wrap(SearchDashboardSnapshots)) }) diff --git a/pkg/api/index.go b/pkg/api/index.go index ca2f9320215..3423651922a 100644 --- a/pkg/api/index.go +++ b/pkg/api/index.go @@ -63,7 +63,7 @@ func setIndexViewData(c *middleware.Context) (*dtos.IndexViewData, error) { data.MainNavLinks = append(data.MainNavLinks, &dtos.NavLink{ Text: "Snapshots", Icon: "fa fa-fw fa-camera-retro", - Url: "/dashboard/snapshots", + Url: "/snapshots", }) if c.OrgRole == m.ROLE_ADMIN { diff --git a/pkg/services/sqlstore/dashboard_snapshot.go b/pkg/services/sqlstore/dashboard_snapshot.go index 6b71a0e26b3..eef2898a7c0 100644 --- a/pkg/services/sqlstore/dashboard_snapshot.go +++ b/pkg/services/sqlstore/dashboard_snapshot.go @@ -68,7 +68,7 @@ func GetDashboardSnapshot(query *m.GetDashboardSnapshotQuery) error { func SearchDashboardSnapshots(query *m.GetDashboardSnapshotsQuery) error { var snapshots = make(m.DashboardSnapshots, 0) - sess := x.Limit(query.Limit) + sess := x.Cols("name,key,delete_key").Limit(query.Limit) if query.Name != "" { sess.Where("name LIKE ?", query.Name) @@ -77,6 +77,5 @@ func SearchDashboardSnapshots(query *m.GetDashboardSnapshotsQuery) error { sess.Where("org_id = ?", query.OrgId) err := sess.Find(&snapshots) query.Result = snapshots - return err }