GC: Remove DeadCode (#1253)
## Description Code removal from GraphConnector `AddItemsToCollection` removed from graph_connector.go ## Type of change - [x] 🐹 Trivial/Minor ## Issue(s) <!-- Can reference multiple issues. Use one of the following "magic words" - "closes, fixes" to auto-close the Github issue. --> * #<issue> ## Test Plan <!-- How will this be tested prior to merging.--> - [ ] 💪 Manual - [x] ⚡ Unit test - [ ] 💚 E2E
This commit is contained in:
parent
0214db9b13
commit
63e1cec71c
@ -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()
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user