CloudMigration: Provide a stats rollup in the GetSnapshot response (#90252)

* order session list descending

* add snapshot status method to store

* query stats while retrieving snapshot

* return stats in dto

* swagger

* fix tests

* commit results of bingo get

* fix swagger

* minor improvement

* fix typo

* forgot a file
This commit is contained in:
Michael Mandrus
2024-07-10 08:46:38 -04:00
committed by GitHub
parent a3dfc894f7
commit 317da43a84
11 changed files with 190 additions and 25 deletions
+27 -17
View File
@@ -17,6 +17,8 @@ var (
)
// CloudMigration domain structs
// CloudMigrationSession represents a configured migration token
type CloudMigrationSession struct {
ID int64 `xorm:"pk autoincr 'id'"`
UID string `xorm:"uid"`
@@ -29,6 +31,7 @@ type CloudMigrationSession struct {
Updated time.Time
}
// CloudMigrationSnapshot contains all of the metadata about a snapshot
type CloudMigrationSnapshot struct {
ID int64 `xorm:"pk autoincr 'id'"`
UID string `xorm:"uid"`
@@ -45,6 +48,8 @@ type CloudMigrationSnapshot struct {
// Stored in the cloud_migration_resource table
Resources []CloudMigrationResource `xorm:"-"`
// Derived by querying the cloud_migration_resource table
StatsRollup SnapshotResourceStats `xorm:"-"`
}
type SnapshotStatus string
@@ -73,6 +78,28 @@ type CloudMigrationResource struct {
SnapshotUID string `xorm:"snapshot_uid"`
}
type MigrateDataType string
const (
DashboardDataType MigrateDataType = "DASHBOARD"
DatasourceDataType MigrateDataType = "DATASOURCE"
FolderDataType MigrateDataType = "FOLDER"
)
type ItemStatus string
const (
ItemStatusOK ItemStatus = "OK"
ItemStatusError ItemStatus = "ERROR"
ItemStatusPending ItemStatus = "PENDING"
ItemStatusUnknown ItemStatus = "UNKNOWN"
)
type SnapshotResourceStats struct {
CountsByType map[MigrateDataType]int
CountsByStatus map[ItemStatus]int
}
// Deprecated, use GetSnapshotResult for the async workflow
func (s CloudMigrationSnapshot) GetResult() (*MigrateDataResponse, error) {
result := MigrateDataResponse{
@@ -154,14 +181,6 @@ type Base64HGInstance struct {
// GMS domain structs
type MigrateDataType string
const (
DashboardDataType MigrateDataType = "DASHBOARD"
DatasourceDataType MigrateDataType = "DATASOURCE"
FolderDataType MigrateDataType = "FOLDER"
)
type MigrateDataRequest struct {
Items []MigrateDataRequestItem
}
@@ -173,15 +192,6 @@ type MigrateDataRequestItem struct {
Data interface{}
}
type ItemStatus string
const (
ItemStatusOK ItemStatus = "OK"
ItemStatusError ItemStatus = "ERROR"
ItemStatusPending ItemStatus = "PENDING"
ItemStatusUnknown ItemStatus = "UNKNOWN"
)
type MigrateDataResponse struct {
RunUID string
Items []CloudMigrationResource