Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fetches lists using Lists client wrapper #4787

Merged
merged 7 commits into from
Dec 5, 2023
Merged

Conversation

HiteshRepo
Copy link
Contributor

fetches lists and its relationships using Lists client wrapper

Does this PR need a docs update or release note?

  • β›” No

Type of change

  • 🌻 Feature

Issue(s)

#4754

Test Plan

  • πŸ’ͺ Manual
  • ⚑ Unit test
  • πŸ’š E2E

Copy link
Contributor

aviator-app bot commented Dec 2, 2023

Current Aviator status

Aviator will automatically update this comment as the status of the PR changes.
Comment /aviator refresh to force Aviator to re-examine your PR (or learn about other /aviator commands).

This PR was merged manually (without Aviator). Merging manually can negatively impact the performance of the queue. Consider using Aviator next time.


See the real-time status of this PR on the Aviator webapp.

Use the Aviator Chrome Extension to see the status of your PR within GitHub.

Copy link
Contributor

@ryanfkeepers ryanfkeepers left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

largely nits. Would like to see the item handling func broken out into its own func and tested. Nothing blocking.

Thanks for breaking up the PRs into separate chunks! It made everything much easier to review.

// but it should be more than one.
assert.Less(t, test.expected, len(collections))
// but it should be more than zero.
assert.Less(t, 0, len(collections))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NotEmpty is what you want here. Both for the nature of the check, and because a failure will show you what's in the collections.

Suggested change
assert.Less(t, 0, len(collections))
assert.NotEmpty(t, collections)

Comment on lines 471 to 472
assert.Equal(t, path.SharePointService.String(), collection.FullPath().Service().String())
assert.Equal(t, path.ListsCategory.String(), collection.FullPath().Category().String())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Service and category are comparable without stringifying.

Suggested change
assert.Equal(t, path.SharePointService.String(), collection.FullPath().Service().String())
assert.Equal(t, path.ListsCategory.String(), collection.FullPath().Category().String())
assert.Equal(t, path.SharePointService, collection.FullPath().Service())
assert.Equal(t, path.ListsCategory, collection.FullPath().Category())

var (
metrics support.CollectionMetrics
el = errs.Local()
objects int64
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: avoid the term objects. Both because golang has no objects, and because it's too generic and easily misunderstood.

Suggested change
objects int64
numLists int64

var lists = []models.Listable{}
defer sc.finishPopulation(ctx, metrics)

// TODO: Insert correct ID for CollectionProgress
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what ID are you referring to?

atomic.AddInt64(&objects, 1)

if err := writer.WriteObjectValue("", entry); err != nil {
err = clues.Wrap(err, "writing list to serializer").Label(fault.LabelForceNoBackupCreation)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please make sure that any error returned by a func that does not take in a ctx in its parameters adds the ctx to the error wrap? This helps ensure we get a complete set of insights into the error.

Suggested change
err = clues.Wrap(err, "writing list to serializer").Label(fault.LabelForceNoBackupCreation)
err = clues.WrapWC(ctx, err, "writing list to serializer").Label(fault.LabelForceNoBackupCreation)


size := int64(len(byteArray))
go func(id string) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While you're in this code, it'd be nice to have this gofunc moved from an ad-hoc func to a fully declared function. That would allow us to write unit tests around that func without having to engage in the full stream processing.

metrics.Successes++

rc := io.NopCloser(bytes.NewReader(entryBytes))
itemID := ptr.Val(entry.GetId())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isn't this the same as the id that the function takes in as a parameter?


metrics.Successes++
var (
entry models.Listable
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: entry is a generic term and doesn't overlap with existing vocabulary, nor does it describe the item.

Suggested change
entry models.Listable
item models.Listable
// alternatively: list

betaService := sc.betaService
if betaService == nil {
return metrics, clues.NewWC(ctx, "beta service required")
logger.Ctx(ctx).Error(clues.New("beta service required"))

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no empty line needed on 2-line returns.

Suggested change

// fullPath indicates the hierarchy within the collection
fullPath path.Path
// jobs contain the SharePoint.Site.ListIDs for the associated list(s).
// jobs contain the SharePoint.List.IDs or SharePoint.Page.IDs
jobs []string
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know it's not strictly part of your change, but we don't use the term jobs anywhere else in the repo. Can you change this to items?

Copy link

sonarcloud bot commented Dec 5, 2023

Kudos, SonarCloud Quality Gate passed!Β  Β  Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 1 Code Smell

No Coverage information No Coverage information
0.0% 0.0% Duplication

@HiteshRepo HiteshRepo merged commit 3971031 into 4754-backup-2 Dec 5, 2023
24 of 25 checks passed
@HiteshRepo HiteshRepo deleted the 4754-backup-3 branch December 5, 2023 18:56
aviator-app bot pushed a commit that referenced this pull request Dec 22, 2023
enables sharepoint to use lists backup handler for lists ops
Changes previously approved in:
-  #4786
- #4787
- #4909

#### Does this PR need a docs update or release note?
- [x] β›” No

#### Type of change

<!--- Please check the type of change your PR introduces: --->
- [x] 🌻 Feature

#### Issue(s)
#4754 

#### Test Plan

<!-- How will this be tested prior to merging.-->
- [x] πŸ’ͺ Manual
- [x] ⚑ Unit test
- [x] πŸ’š E2E
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backup lists category of sharepoint service sharepoint
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants