vchunikhin commented on code in PR #22967:
URL: https://github.com/apache/beam/pull/22967#discussion_r960791916


##########
learning/tour-of-beam/backend/internal/storage/datastore.go:
##########
@@ -227,5 +227,34 @@ func (d *DatastoreDb) SaveContentTrees(ctx 
context.Context, trees []tob.ContentT
        return nil
 }
 
+// Get learning unit content by unitId
+func (d *DatastoreDb) GetUnitContent(ctx context.Context, sdk tob.Sdk, unitId 
string) (unit *tob.Unit, err error) {
+       var tbNodes []TbLearningNode
+       rootKey := pgNameKey(TbLearningPathKind, sdkToKey(sdk), nil)
+
+       query := datastore.NewQuery(TbLearningNodeKind).
+               Namespace(PgNamespace).
+               Ancestor(rootKey).
+               FilterField("id", "=", unitId)
+
+       _, err = d.Client.GetAll(ctx, query, &tbNodes)
+       if err != nil {
+               return nil, fmt.Errorf("query unit failed: %w", err)
+       }
+
+       switch {
+       case len(tbNodes) == 0:
+               return nil, nil

Review Comment:
   Ok, make sense, lgtm



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to