[API-69] Implement managed users endpoint#69
Merged
Conversation
raymondjacobson
approved these changes
May 5, 2025
Member
raymondjacobson
left a comment
There was a problem hiding this comment.
not blocking, but code could be a little tighter I think
* origin/main: improve json assert Pin versions of tooling in setup (#67)
stereosteve
reviewed
May 6, 2025
| value = &parsed | ||
| } | ||
| return pgtype.Bool{Bool: value != nil && *value, Valid: value != nil}, nil | ||
| } |
Contributor
There was a problem hiding this comment.
This can be written more simple like:
func getOptionalBool(c *fiber.Ctx, key string) (pgtype.Bool, error) {
if valueStr := c.Query(key); valueStr != "" {
parsed, err := strconv.ParseBool(c.Query(key))
if err != nil {
return pgtype.Bool{}, err
}
return pgtype.Bool{Bool: parsed, Valid: true}, nil
}
return pgtype.Bool{}, nil
}
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow on to #65 which implements the managed users endpoint.
The query is very similar but it needs to select the user by id and join grants by their wallet address. And the resulting JSON for each record uses
{ user, grant }instead of{ manager, grant }.Fun thing: My original queries were missing parens around the OR clause at the end and that duped me into thinking things were really broken...
I also learned that if you put the
IS NULLcheck first on asqlc.narg()param, it won't generate the correct type (will give you aninterface {}instead of a nullable boolean). But if it's last, things work correctly 🤷