mirror of
https://github.com/grafana/grafana.git
synced 2025-07-31 10:02:33 +08:00

* Add store split for Get Dashboard version method * Implement dashboard version service * Fix api tests * Remove GetDashboarVersion from sqlstore * Add fakes for Get dashboard version * Fix sqlstore test * Add Get Dashboard store test * Add dashver service test * Remove useless comments
31 lines
642 B
Go
31 lines
642 B
Go
package dashverimpl
|
|
|
|
import (
|
|
"context"
|
|
|
|
dashver "github.com/grafana/grafana/pkg/services/dashboardversion"
|
|
"github.com/grafana/grafana/pkg/services/sqlstore/db"
|
|
"github.com/grafana/grafana/pkg/setting"
|
|
)
|
|
|
|
type Service struct {
|
|
store store
|
|
}
|
|
|
|
func ProvideService(db db.DB, cfg *setting.Cfg) dashver.Service {
|
|
return &Service{
|
|
store: &sqlStore{
|
|
db: db,
|
|
},
|
|
}
|
|
}
|
|
|
|
func (s *Service) Get(ctx context.Context, query *dashver.GetDashboardVersionQuery) (*dashver.DashboardVersion, error) {
|
|
version, err := s.store.Get(ctx, query)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
version.Data.Set("id", version.DashboardID)
|
|
return version, nil
|
|
}
|