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

fix(gae): delete old region tags #5102

Conversation

OremGLG
Copy link
Contributor

@OremGLG OremGLG commented Jan 22, 2025

Description

Delete old region tags

Fixes
b/391176362
b/389106593
b/391176883
b/391175192
b/391176374
b/391176575
b/391175195
b/391176890

Note: Before submitting a pull request, please open an issue for discussion if you are not associated with Google.

Checklist

  • I have followed Contributing Guidelines from CONTRIBUTING.MD
  • Tests pass: go test -v ./.. (see Testing)
  • Code formatted: gofmt (see Formatting)
  • Vetting pass: go vet (see Formatting)
  • These samples need a new API enabled in testing projects to pass (let us know which ones)
  • These samples need a new/updated env vars in testing projects set to pass (let us know which ones)
  • This sample adds a new sample directory, and I updated the CODEOWNERS file with the codeowners for this sample
  • This sample adds a new Product API, and I updated the Blunderbuss issue/PR auto-assigner with the codeowners for this sample
  • Please merge this PR for me once it is approved

@product-auto-label product-auto-label bot added the samples Issues that are directly related to samples. label Jan 22, 2025
Copy link

@code-review-assist code-review-assist bot left a comment

Choose a reason for hiding this comment

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

Hi team,

I'm currently reviewing this pull request and will provide feedback shortly. In the meantime, here's a summary for you and other reviewers to quickly get up to speed:

This pull request, submitted by OremGLG, aims to delete old region tags in the golang-samples repository. The changes are driven by the need to address several issues (b/391176362, b/389106593, b/391176883, b/391175192, b/391176374, b/391176575, b/391175195, b/391176890).

Here's a breakdown of the changes:

  • The file docs/appengine/datastore/entities/entities.go has been modified. Specifically, lines 34-35, 44, 51, 60, 71, 83, 92, 99, 116, and 125 have been altered. These changes appear to remove several instances of outdated region tags (// [START ... ] and // [END ... ]) from code comments.

The author has indicated that the code is formatted (gofmt) and vetted (go vet), and the contributing guidelines have been followed. However, tests are not yet complete.

I'll provide a more detailed review shortly.


And now, a little haiku to brighten your day:

Tags cleaned, code refined,
Clarity shines, a brighter view,
Review now complete.

Copy link

@code-review-assist code-review-assist bot left a comment

Choose a reason for hiding this comment

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

This pull request removes redundant region tags from the entities.go file. Removing these tags improves the clarity and maintainability of the code, as it avoids potential confusion caused by duplicate tags. The changes are well-targeted and effectively address the identified issues related to redundant region tags. I recommend adding tests to verify the correctness of the code after these changes, as described in the Contributing Guidelines. I've also noticed that the checklist in the pull request description is not fully completed. Please ensure that all items in the checklist are addressed before merging.

@@ -31,7 +31,6 @@ type Address struct{}

func example() {
// [START gae_datastore_batch]
// [START batch]

Choose a reason for hiding this comment

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

medium

This line was removed. Was this intentional? If the removal was unintentional, please add the line back. Otherwise, the removal of the redundant tag is correct per the purpose of this pull request.

Comment on lines 40 to 44

// A batch delete.
err = datastore.DeleteMulti(ctx, []*datastore.Key{k1, k2, k3})
// [END batch]
// [END gae_datastore_batch]
_ = err

Choose a reason for hiding this comment

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

low

The redundant batch tag has been correctly removed. Consider adding a comment explaining the purpose of the datastore.DeleteMulti function and its usage in the context of batch operations. For example, you could add a comment like this:

// Delete multiple entities in a batch operation.
// This is more efficient than deleting them individually.
Suggested change
// A batch delete.
err = datastore.DeleteMulti(ctx, []*datastore.Key{k1, k2, k3})
// [END batch]
// [END gae_datastore_batch]
_ = err
// A batch delete.
err = datastore.DeleteMulti(ctx, []*datastore.Key{k1, k2, k3})
// [END gae_datastore_batch]
_ = err

Comment on lines 49 to 50
key := datastore.NewKey(ctx, "Employee", "asalieri", 0, nil)
err = datastore.Delete(ctx, key)

Choose a reason for hiding this comment

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

low

The removal of the delete region tag is appropriate. To improve code readability, consider adding a comment that explains the purpose of this code block, such as:

// Delete a single entity from the datastore.
Suggested change
key := datastore.NewKey(ctx, "Employee", "asalieri", 0, nil)
err = datastore.Delete(ctx, key)
key := datastore.NewKey(ctx, "Employee", "asalieri", 0, nil)
err = datastore.Delete(ctx, key)

Comment on lines 56 to 59
employeeKey := datastore.NewKey(ctx, "Employee", "asalieri", 0, nil)
addressKey := datastore.NewKey(ctx, "Address", "", 1, employeeKey)
var addr Address
err = datastore.Get(ctx, addressKey, &addr)

Choose a reason for hiding this comment

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

low

Removing the get_key tag is correct. To enhance code clarity, consider adding a comment explaining the purpose of retrieving the address using datastore.Get, such as:

// Retrieve an Address entity from the datastore using its key.
Suggested change
employeeKey := datastore.NewKey(ctx, "Employee", "asalieri", 0, nil)
addressKey := datastore.NewKey(ctx, "Address", "", 1, employeeKey)
var addr Address
err = datastore.Get(ctx, addressKey, &addr)
employeeKey := datastore.NewKey(ctx, "Employee", "asalieri", 0, nil)
addressKey := datastore.NewKey(ctx, "Address", "", 1, employeeKey)
var addr Address
err = datastore.Get(ctx, addressKey, &addr)

Comment on lines 65 to 68
// Create a key such as Employee:8261.
key := datastore.NewKey(ctx, "Employee", "", 0, nil)
// This is equivalent:
key = datastore.NewIncompleteKey(ctx, "Employee", nil)

Choose a reason for hiding this comment

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

low

The key_id tag was removed correctly. Consider adding a comment explaining the purpose of creating keys with and without IDs, for example:

// Demonstrates creating keys with and without explicit IDs.
// An incomplete key generates an ID automatically.
Suggested change
// Create a key such as Employee:8261.
key := datastore.NewKey(ctx, "Employee", "", 0, nil)
// This is equivalent:
key = datastore.NewIncompleteKey(ctx, "Employee", nil)
// Create a key such as Employee:8261.
key := datastore.NewKey(ctx, "Employee", "", 0, nil)
// This is equivalent:
key = datastore.NewIncompleteKey(ctx, "Employee", nil)

@OremGLG OremGLG marked this pull request as ready for review January 24, 2025 16:11
@OremGLG OremGLG requested review from a team as code owners January 24, 2025 16:11
Copy link

snippet-bot bot commented Jan 24, 2025

Here is the summary of changes.

You are about to delete 8 region tags.

This comment is generated by snippet-bot.
If you find problems with this result, please file an issue at:
https://github.com/googleapis/repo-automation-bots/issues.
To update this comment, add snippet-bot:force-run label or use the checkbox below:

  • Refresh this comment

@iennae iennae merged commit e3276e0 into GoogleCloudPlatform:main Jan 26, 2025
8 checks passed
@OremGLG OremGLG deleted the garciadiaz-migrate-region-step-2-entities branch January 27, 2025 17:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
samples Issues that are directly related to samples.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants