Chore: Use context.Context for the get home dashboard API endpoint (#36735)
Use context.Context for the get home dashboard API endpoint. Ref #36734
This commit is contained in:
@@ -33,7 +33,6 @@ func init() {
|
||||
bus.AddHandler("sql", SearchDashboards)
|
||||
bus.AddHandler("sql", GetDashboardTags)
|
||||
bus.AddHandler("sql", GetDashboardSlugById)
|
||||
bus.AddHandler("sql", GetDashboardUIDById)
|
||||
bus.AddHandler("sql", GetDashboardsByPluginId)
|
||||
bus.AddHandler("sql", GetDashboardPermissionsForUser)
|
||||
bus.AddHandler("sql", GetDashboardsBySlug)
|
||||
@@ -43,6 +42,10 @@ func init() {
|
||||
prometheus.MustRegister(shadowSearchCounter)
|
||||
}
|
||||
|
||||
func (ss *SQLStore) addDashboardQueryAndCommandHandlers() {
|
||||
bus.AddHandlerCtx("sql", ss.GetDashboardUIDById)
|
||||
}
|
||||
|
||||
var generateNewUid func() string = util.GenerateShortUID
|
||||
|
||||
func (ss *SQLStore) SaveDashboard(cmd models.SaveDashboardCommand) (*models.Dashboard, error) {
|
||||
@@ -623,21 +626,23 @@ func GetDashboardsBySlug(query *models.GetDashboardsBySlugQuery) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func GetDashboardUIDById(query *models.GetDashboardRefByIdQuery) error {
|
||||
var rawSQL = `SELECT uid, slug from dashboard WHERE Id=?`
|
||||
func (ss *SQLStore) GetDashboardUIDById(ctx context.Context, query *models.GetDashboardRefByIdQuery) error {
|
||||
return ss.WithDbSession(ctx, func(dbSession *DBSession) error {
|
||||
var rawSQL = `SELECT uid, slug from dashboard WHERE Id=?`
|
||||
|
||||
us := &models.DashboardRef{}
|
||||
us := &models.DashboardRef{}
|
||||
|
||||
exists, err := x.SQL(rawSQL, query.Id).Get(us)
|
||||
exists, err := dbSession.SQL(rawSQL, query.Id).Get(us)
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
} else if !exists {
|
||||
return models.ErrDashboardNotFound
|
||||
}
|
||||
if err != nil {
|
||||
return err
|
||||
} else if !exists {
|
||||
return models.ErrDashboardNotFound
|
||||
}
|
||||
|
||||
query.Result = us
|
||||
return nil
|
||||
query.Result = us
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
||||
func getExistingDashboardByIdOrUidForUpdate(sess *DBSession, dash *models.Dashboard, overwrite bool) (bool, error) {
|
||||
|
||||
Reference in New Issue
Block a user