Skip to content

Commit

Permalink
Playlist: Add create+update timestamps to the database (grafana#76295)
Browse files Browse the repository at this point in the history
  • Loading branch information
ryantxu authored Oct 10, 2023
1 parent 3d84956 commit c26e3d8
Show file tree
Hide file tree
Showing 9 changed files with 81 additions and 328 deletions.
2 changes: 1 addition & 1 deletion .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@
/pkg/services/navtree/ @grafana/backend-platform
/pkg/services/notifications/ @grafana/backend-platform
/pkg/services/org/ @grafana/backend-platform
/pkg/services/playlist/ @grafana/backend-platform
/pkg/services/playlist/ @grafana/grafana-app-platform-squad
/pkg/services/plugindashboards/ @grafana/backend-platform
/pkg/services/preference/ @grafana/backend-platform
/pkg/services/provisioning/ @grafana/backend-platform
Expand Down
13 changes: 10 additions & 3 deletions pkg/services/playlist/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,8 @@ import (

// Typed errors
var (
ErrPlaylistNotFound = errors.New("Playlist not found")
ErrPlaylistFailedGenerateUniqueUid = errors.New("failed to generate unique playlist UID")
ErrCommandValidationFailed = errors.New("command missing required fields")
ErrPlaylistNotFound = errors.New("Playlist not found")
ErrCommandValidationFailed = errors.New("command missing required fields")
)

// Playlist model
Expand All @@ -20,6 +19,12 @@ type Playlist struct {
Name string `json:"name" db:"name"`
Interval string `json:"interval" db:"interval"`
OrgId int64 `json:"-" db:"org_id"`

// Added for kubernetes migration + synchronization
// Hidden from json because this is used for openapi generation
// Using int64 rather than time.Time to avoid database issues with time support
CreatedAt int64 `json:"-" db:"created_at"`
UpdatedAt int64 `json:"-" db:"updated_at"`
}

type PlaylistDTO = playlist.Spec
Expand Down Expand Up @@ -54,6 +59,8 @@ type CreatePlaylistCommand struct {
Interval string `json:"interval"`
Items []PlaylistItem `json:"items"`
OrgId int64 `json:"-"`
// Used to create playlists from kubectl with a known uid/name
UID string `json:"-"`
}

type DeletePlaylistCommand struct {
Expand Down
64 changes: 0 additions & 64 deletions pkg/services/playlist/model_test.go

This file was deleted.

13 changes: 2 additions & 11 deletions pkg/services/playlist/playlistimpl/playlist.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,8 @@ type Service struct {
var _ playlist.Service = &Service{}

func ProvideService(db db.DB, toggles featuremgmt.FeatureToggles, objserver entity.EntityStoreServer) playlist.Service {
var sqlstore store

// 🐢🐢🐢 pick the store
if toggles.IsEnabled(featuremgmt.FlagNewDBLibrary) {
sqlstore = &sqlxStore{
sess: db.GetSqlxSession(),
}
} else {
sqlstore = &sqlStore{
db: db,
}
sqlstore := &sqlStore{
db: db,
}
return &Service{store: sqlstore}
}
Expand Down
201 changes: 0 additions & 201 deletions pkg/services/playlist/playlistimpl/sqlx_store.go

This file was deleted.

16 changes: 0 additions & 16 deletions pkg/services/playlist/playlistimpl/sqlx_store_test.go

This file was deleted.

Loading

0 comments on commit c26e3d8

Please sign in to comment.