mirror of
https://github.com/grafana/grafana.git
synced 2024-12-27 09:21:35 -06:00
3d3a7cbba8
* Chore: Fix issues reported by staticcheck Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com> * Undo changes Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com> * Chore: Fix issues reported by staticcheck Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com> * Fix test Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com> * Fix test Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>
87 lines
2.3 KiB
Go
87 lines
2.3 KiB
Go
package models
|
|
|
|
import (
|
|
"errors"
|
|
"time"
|
|
|
|
"github.com/grafana/grafana/pkg/components/simplejson"
|
|
)
|
|
|
|
var (
|
|
ErrDashboardVersionNotFound = errors.New("dashboard version not found")
|
|
ErrNoVersionsForDashboardId = errors.New("no dashboard versions found for the given DashboardId")
|
|
)
|
|
|
|
// A DashboardVersion represents the comparable data in a dashboard, allowing
|
|
// diffs of the dashboard to be performed.
|
|
type DashboardVersion struct {
|
|
Id int64 `json:"id"`
|
|
DashboardId int64 `json:"dashboardId"`
|
|
ParentVersion int `json:"parentVersion"`
|
|
RestoredFrom int `json:"restoredFrom"`
|
|
Version int `json:"version"`
|
|
|
|
Created time.Time `json:"created"`
|
|
CreatedBy int64 `json:"createdBy"`
|
|
|
|
Message string `json:"message"`
|
|
Data *simplejson.Json `json:"data"`
|
|
}
|
|
|
|
// DashboardVersionMeta extends the dashboard version model with the names
|
|
// associated with the UserIds, overriding the field with the same name from
|
|
// the DashboardVersion model.
|
|
type DashboardVersionMeta struct {
|
|
Id int64 `json:"id"`
|
|
DashboardId int64 `json:"dashboardId"`
|
|
ParentVersion int `json:"parentVersion"`
|
|
RestoredFrom int `json:"restoredFrom"`
|
|
Version int `json:"version"`
|
|
Created time.Time `json:"created"`
|
|
Message string `json:"message"`
|
|
Data *simplejson.Json `json:"data"`
|
|
CreatedBy string `json:"createdBy"`
|
|
}
|
|
|
|
// DashboardVersionDTO represents a dashboard version, without the dashboard
|
|
// map.
|
|
type DashboardVersionDTO struct {
|
|
Id int64 `json:"id"`
|
|
DashboardId int64 `json:"dashboardId"`
|
|
ParentVersion int `json:"parentVersion"`
|
|
RestoredFrom int `json:"restoredFrom"`
|
|
Version int `json:"version"`
|
|
Created time.Time `json:"created"`
|
|
CreatedBy string `json:"createdBy"`
|
|
Message string `json:"message"`
|
|
}
|
|
|
|
//
|
|
// Queries
|
|
//
|
|
|
|
type GetDashboardVersionQuery struct {
|
|
DashboardId int64
|
|
OrgId int64
|
|
Version int
|
|
|
|
Result *DashboardVersion
|
|
}
|
|
|
|
type GetDashboardVersionsQuery struct {
|
|
DashboardId int64
|
|
OrgId int64
|
|
Limit int
|
|
Start int
|
|
|
|
Result []*DashboardVersionDTO
|
|
}
|
|
|
|
//
|
|
// Commands
|
|
//
|
|
|
|
type DeleteExpiredVersionsCommand struct {
|
|
DeletedRows int64
|
|
}
|