diff --git a/CHANGELOG.md b/CHANGELOG.md index 77244b734..83a8985cb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed - When running `backup details` on an empty backup returns a more helpful error message. +- Backup List additionally shows the data category for each backup. ### Known issues - Backing up a group mailbox item may fail if it has a very large number of attachments (500+). diff --git a/src/pkg/backup/backup.go b/src/pkg/backup/backup.go index ff1dfdd93..cc51b588a 100644 --- a/src/pkg/backup/backup.go +++ b/src/pkg/backup/backup.go @@ -3,6 +3,7 @@ package backup import ( "context" "fmt" + "sort" "strconv" "strings" "time" @@ -16,6 +17,7 @@ import ( "github.com/alcionai/corso/src/internal/version" "github.com/alcionai/corso/src/pkg/dttm" "github.com/alcionai/corso/src/pkg/fault" + "github.com/alcionai/corso/src/pkg/logger" "github.com/alcionai/corso/src/pkg/selectors" ) @@ -226,17 +228,19 @@ func (b Backup) MinimumPrintable() any { // for printing out to a terminal in a columnar display. func (b Backup) Headers(skipID bool) []string { headers := []string{ - "Started At", + "ID", + "Started at", "Duration", "Status", - "Resource Owner", + "Protected resource", + "Data", } if skipID { - return headers + headers = headers[1:] } - return append([]string{"ID"}, headers...) + return headers } // Values returns the values matching the Headers list for printing @@ -292,18 +296,33 @@ func (b Backup) Values(skipID bool) []string { bs := b.toStats() + reasons, err := b.Selector.Reasons("doesnt-matter", false) + if err != nil { + logger.CtxErr(context.Background(), err).Error("getting reasons from selector") + } + + reasonCats := []string{} + + for _, r := range reasons { + reasonCats = append(reasonCats, r.Category().HumanString()) + } + + sort.Strings(reasonCats) + values := []string{ + string(b.ID), dttm.FormatToTabularDisplay(b.StartedAt), bs.EndedAt.Sub(bs.StartedAt).String(), status, name, + strings.Join(reasonCats, ","), } if skipID { - return values + values = values[1:] } - return append([]string{string(b.ID)}, values...) + return values } // ----- print backup stats diff --git a/src/pkg/backup/backup_test.go b/src/pkg/backup/backup_test.go index b040e5d28..f2200b48a 100644 --- a/src/pkg/backup/backup_test.go +++ b/src/pkg/backup/backup_test.go @@ -155,10 +155,11 @@ func (suite *BackupUnitSuite) TestBackup_HeadersValues() { b = stubBackup(now, "id", "name") expectHs = []string{ "ID", - "Started At", + "Started at", "Duration", "Status", - "Resource Owner", + "Protected resource", + "Data", } nowFmt = dttm.FormatToTabularDisplay(now) expectVs = []string{ @@ -167,6 +168,7 @@ func (suite *BackupUnitSuite) TestBackup_HeadersValues() { "1m0s", "status (2 errors, 1 skipped: 1 malware)", "name-pr", + "Contacts,Emails,Events", } ) @@ -194,10 +196,11 @@ func (suite *BackupUnitSuite) TestBackup_HeadersValues_onlyResourceOwners() { b = stubBackup(now, "id", "name") expectHs = []string{ "ID", - "Started At", + "Started at", "Duration", "Status", - "Resource Owner", + "Protected resource", + "Data", } nowFmt = dttm.FormatToTabularDisplay(now) expectVs = []string{ @@ -206,6 +209,7 @@ func (suite *BackupUnitSuite) TestBackup_HeadersValues_onlyResourceOwners() { "1m0s", "status (2 errors, 1 skipped: 1 malware)", "name-ro", + "Contacts,Emails,Events", } )