Skip to content

[API-69] Add user managers endpoint#65

Merged
schottra merged 2 commits intomainfrom
grants-endpoints
May 5, 2025
Merged

[API-69] Add user managers endpoint#65
schottra merged 2 commits intomainfrom
grants-endpoints

Conversation

@schottra
Copy link
Copy Markdown
Contributor

@schottra schottra commented May 2, 2025

Adds v1/full/users/:userId/managers endpoint with tests.
I'll do the managed users in a separate PR in case there are any big changes requested here. They are very similar in functionality just make the request based on different filters.

The changes in all the other generated files are due to me reinstalling deps and getting a minor version bump on sqlc.

WHERE g.grantee_address = @grantee_address
AND g.is_current = true
AND g.is_revoked = @is_revoked
AND sqlc.narg('is_approved')::boolean IS NULL OR g.is_approved = sqlc.narg('is_approved')
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Does this work? If you're casting to a boolean will it ever be null?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I'm also confused by it, but it does appear to work (verified by tests)

@schottra schottra merged commit 8380302 into main May 5, 2025
2 checks passed
@schottra schottra deleted the grants-endpoints branch May 5, 2025 15:35
schottra added a commit that referenced this pull request May 6, 2025
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 NULL` check first on a
`sqlc.narg()` param, it won't generate the correct type (will give you
an `interface {}` instead of a nullable boolean). But if it's last,
things work correctly 🤷
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants