Chore: Remove Result field from dashboard snapshot mode (#62089)

Chore: Remove Result field from dashboard snapshot mode;
This commit is contained in:
idafurjes
2023-01-25 15:09:44 +01:00
committed by GitHub
parent 13de1afcbe
commit 529e6c379f
12 changed files with 220 additions and 182 deletions
+9 -9
View File
@@ -256,34 +256,34 @@ func (e *entityStoreJob) start(ctx context.Context) {
rowUser.OrgID = orgId
rowUser.UserID = 1
cmd := &dashboardsnapshots.GetDashboardSnapshotsQuery{
OrgId: orgId,
OrgID: orgId,
Limit: 500000,
SignedInUser: rowUser,
}
err := e.dashboardsnapshots.SearchDashboardSnapshots(ctx, cmd)
result, err := e.dashboardsnapshots.SearchDashboardSnapshots(ctx, cmd)
if err != nil {
e.status.Status = "error: " + err.Error()
return
}
for _, dto := range cmd.Result {
for _, dto := range result {
m := snapshot.Model{
Name: dto.Name,
ExternalURL: dto.ExternalUrl,
ExternalURL: dto.ExternalURL,
Expires: dto.Expires.UnixMilli(),
}
rowUser.OrgID = dto.OrgId
rowUser.UserID = dto.UserId
rowUser.OrgID = dto.OrgID
rowUser.UserID = dto.UserID
snapcmd := &dashboardsnapshots.GetDashboardSnapshotQuery{
Key: dto.Key,
}
err = e.dashboardsnapshots.GetDashboardSnapshot(ctx, snapcmd)
snapcmdResult, err := e.dashboardsnapshots.GetDashboardSnapshot(ctx, snapcmd)
if err == nil {
res := snapcmd.Result
res := snapcmdResult
m.DeleteKey = res.DeleteKey
m.ExternalURL = res.ExternalUrl
m.ExternalURL = res.ExternalURL
snap := res.Dashboard
m.DashboardUID = snap.Get("uid").MustString("")
+5 -5
View File
@@ -10,7 +10,7 @@ import (
func exportSnapshots(helper *commitHelper, job *gitExportJob) error {
cmd := &dashboardsnapshots.GetDashboardSnapshotsQuery{
OrgId: helper.orgID,
OrgID: helper.orgID,
Limit: 500000,
SignedInUser: nil,
}
@@ -18,12 +18,12 @@ func exportSnapshots(helper *commitHelper, job *gitExportJob) error {
return fmt.Errorf("snapshots requires an admin user")
}
err := job.dashboardsnapshotsService.SearchDashboardSnapshots(helper.ctx, cmd)
result, err := job.dashboardsnapshotsService.SearchDashboardSnapshots(helper.ctx, cmd)
if err != nil {
return err
}
if len(cmd.Result) < 1 {
if len(result) < 1 {
return nil // nothing
}
@@ -32,9 +32,9 @@ func exportSnapshots(helper *commitHelper, job *gitExportJob) error {
comment: "Export snapshots",
}
for _, snapshot := range cmd.Result {
for _, snapshot := range result {
gitcmd.body = append(gitcmd.body, commitBody{
fpath: filepath.Join(helper.orgDir, "snapshot", fmt.Sprintf("%d-snapshot.json", snapshot.Id)),
fpath: filepath.Join(helper.orgDir, "snapshot", fmt.Sprintf("%d-snapshot.json", snapshot.ID)),
body: prettyJSON(snapshot),
})
}