Chore: Remove x from session (#48074)

pull/48083/head
Kat Yang 3 years ago committed by GitHub
parent d66fc6ed1a
commit 8e606dd751
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 10
      pkg/services/sqlstore/alert_notification.go
  2. 4
      pkg/services/sqlstore/session.go
  3. 4
      pkg/services/sqlstore/tags_test.go

@ -54,7 +54,7 @@ func (ss *SQLStore) DeleteAlertNotification(ctx context.Context, cmd *models.Del
func (ss *SQLStore) DeleteAlertNotificationWithUid(ctx context.Context, cmd *models.DeleteAlertNotificationWithUidCommand) error {
existingNotification := &models.GetAlertNotificationsWithUidQuery{OrgId: cmd.OrgId, Uid: cmd.Uid}
if err := getAlertNotificationWithUidInternal(ctx, existingNotification, newSession(ctx)); err != nil {
if err := getAlertNotificationWithUidInternal(ctx, existingNotification, ss.newSession(ctx)); err != nil {
return err
}
@ -75,7 +75,7 @@ func (ss *SQLStore) DeleteAlertNotificationWithUid(ctx context.Context, cmd *mod
}
func (ss *SQLStore) GetAlertNotifications(ctx context.Context, query *models.GetAlertNotificationsQuery) error {
return getAlertNotificationInternal(ctx, query, newSession(ctx))
return getAlertNotificationInternal(ctx, query, ss.newSession(ctx))
}
func (ss *SQLStore) GetAlertNotificationUidWithId(ctx context.Context, query *models.GetAlertNotificationUidQuery) error {
@ -86,7 +86,7 @@ func (ss *SQLStore) GetAlertNotificationUidWithId(ctx context.Context, query *mo
return nil
}
err := getAlertNotificationUidInternal(ctx, query, newSession(ctx))
err := getAlertNotificationUidInternal(ctx, query, ss.newSession(ctx))
if err != nil {
return err
}
@ -101,7 +101,7 @@ func newAlertNotificationUidCacheKey(orgID, notificationId int64) string {
}
func (ss *SQLStore) GetAlertNotificationsWithUid(ctx context.Context, query *models.GetAlertNotificationsWithUidQuery) error {
return getAlertNotificationWithUidInternal(ctx, query, newSession(ctx))
return getAlertNotificationWithUidInternal(ctx, query, ss.newSession(ctx))
}
func (ss *SQLStore) GetAllAlertNotifications(ctx context.Context, query *models.GetAllAlertNotificationsQuery) error {
@ -440,7 +440,7 @@ func (ss *SQLStore) UpdateAlertNotification(ctx context.Context, cmd *models.Upd
func (ss *SQLStore) UpdateAlertNotificationWithUid(ctx context.Context, cmd *models.UpdateAlertNotificationWithUidCommand) error {
getAlertNotificationWithUidQuery := &models.GetAlertNotificationsWithUidQuery{OrgId: cmd.OrgId, Uid: cmd.Uid}
if err := getAlertNotificationWithUidInternal(ctx, getAlertNotificationWithUidQuery, newSession(ctx)); err != nil {
if err := getAlertNotificationWithUidInternal(ctx, getAlertNotificationWithUidQuery, ss.newSession(ctx)); err != nil {
return err
}

@ -30,8 +30,8 @@ func (ss *SQLStore) NewSession(ctx context.Context) *DBSession {
return sess
}
func newSession(ctx context.Context) *DBSession {
sess := &DBSession{Session: x.NewSession()}
func (ss *SQLStore) newSession(ctx context.Context) *DBSession {
sess := &DBSession{Session: ss.engine.NewSession()}
sess.Session = sess.Session.Context(ctx)
return sess

@ -13,7 +13,7 @@ import (
)
func TestSavingTags(t *testing.T) {
InitTestDB(t)
ss := InitTestDB(t)
tagPairs := []*models.Tag{
{Key: "outage"},
@ -21,7 +21,7 @@ func TestSavingTags(t *testing.T) {
{Key: "server", Value: "server-1"},
{Key: "error"},
}
tags, err := EnsureTagsExist(newSession(context.Background()), tagPairs)
tags, err := EnsureTagsExist(ss.newSession(context.Background()), tagPairs)
require.Nil(t, err)
require.Equal(t, 4, len(tags))

Loading…
Cancel
Save