From 63e1cec71c4e619a933a06f47ed1dfe7ebc49ba1 Mon Sep 17 00:00:00 2001 From: Danny Date: Thu, 20 Oct 2022 13:54:36 -0400 Subject: [PATCH] GC: Remove DeadCode (#1253) ## Description Code removal from GraphConnector `AddItemsToCollection` removed from graph_connector.go ## Type of change - [x] :hamster: Trivial/Minor ## Issue(s) * # ## Test Plan - [ ] :muscle: Manual - [x] :zap: Unit test - [ ] :green_heart: E2E --- .../connector/exchange/service_functions.go | 77 ------------------- 1 file changed, 77 deletions(-) diff --git a/src/internal/connector/exchange/service_functions.go b/src/internal/connector/exchange/service_functions.go index 4b8b931c7..5fd99448b 100644 --- a/src/internal/connector/exchange/service_functions.go +++ b/src/internal/connector/exchange/service_functions.go @@ -4,14 +4,11 @@ import ( "context" "fmt" - "github.com/hashicorp/go-multierror" msgraphsdk "github.com/microsoftgraph/msgraph-sdk-go" - msgraphgocore "github.com/microsoftgraph/msgraph-sdk-go-core" "github.com/microsoftgraph/msgraph-sdk-go/models" "github.com/pkg/errors" "github.com/alcionai/corso/src/internal/connector/graph" - "github.com/alcionai/corso/src/internal/connector/support" "github.com/alcionai/corso/src/pkg/account" "github.com/alcionai/corso/src/pkg/path" "github.com/alcionai/corso/src/pkg/selectors" @@ -332,77 +329,3 @@ func pathAndMatch(qp graph.QueryParams, category path.CategoryType, c graph.Cach return nil, false } } - -func AddItemsToCollection( - ctx context.Context, - gs graph.Service, - userID string, - folderID string, - collection *Collection, -) error { - // TODO(ashmrtn): This can be removed when: - // 1. other data types have caching support - // 2. we have a good way to switch between the query for items for each data - // type. - // 3. the below is updated to handle different data categories - // - // The alternative would be to eventually just have collections fetch items as - // they are read. This would allow for streaming all items instead of pulling - // the IDs and then later fetching all the item data. - if collection.FullPath().Category() != path.EmailCategory { - return errors.Errorf( - "unsupported data type %s", - collection.FullPath().Category().String(), - ) - } - - options, err := optionsForFolderMessages([]string{"id"}) - if err != nil { - return errors.Wrap(err, "getting query options") - } - - messageResp, err := gs.Client().UsersById(userID).MailFoldersById(folderID).Messages().Get(ctx, options) - if err != nil { - return errors.Wrap( - errors.Wrap(err, support.ConnectorStackErrorTrace(err)), - "initial folder query", - ) - } - - pageIter, err := msgraphgocore.NewPageIterator( - messageResp, - gs.Adapter(), - models.CreateMessageCollectionResponseFromDiscriminatorValue, - ) - if err != nil { - return errors.Wrap(err, "creating graph iterator") - } - - var errs *multierror.Error - - err = pageIter.Iterate(ctx, func(got any) bool { - item, ok := got.(graph.Idable) - if !ok { - errs = multierror.Append(errs, errors.New("item without ID function")) - return true - } - - if item.GetId() == nil { - errs = multierror.Append(errs, errors.New("item with nil ID")) - return true - } - - collection.AddJob(*item.GetId()) - - return true - }) - - if err != nil { - errs = multierror.Append(errs, errors.Wrap( - errors.Wrap(err, support.ConnectorStackErrorTrace(err)), - "getting folder messages", - )) - } - - return errs.ErrorOrNil() -}