Skip to content

ref(hc): Introduce RpcUserProfile and UserService.get_many_profiles #68847

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

Merged
merged 3 commits into from
Apr 17, 2024

Conversation

RyanSkonnord
Copy link
Contributor

Offer a more performant alternative to UserService.get_many that provides all attributes that can be provided without fetching from any related tables.

Rename ids_only to more accurately reflect what it does, since get_many_profiles is now using it to fetch more than just IDs but still wants to avoid selecting any related data.

Make query_many no longer private by convention. We now want to call it directly, so that we can then do a different kind of serialization than _UserFilterQuery's default. (DatabaseBackedUserSocialAuthService also was previously calling it directly.)

Offer a more performant alternative to UserService.get_many that
provides all attributes that can be provided without fetching from any
related tables.
Rename `ids_only` to more accurately reflect what it does, since
`get_many_profiles` is now using it to fetch more than just IDs but
still wants to avoid selecting any related data.

Make `query_many` no longer private by convention. We now want to call
it directly, so that we can then do a different kind of serialization
than _UserFilterQuery's default. (DatabaseBackedUserSocialAuthService
also was previously calling it directly.)
@RyanSkonnord RyanSkonnord requested a review from a team as a code owner April 12, 2024 23:15
@github-actions github-actions bot added the Scope: Backend Automatically applied to PRs that change backend components label Apr 12, 2024
@@ -34,12 +34,13 @@ class RpcAuthenticator(RpcModel):
config: Any = None


class RpcUser(RpcModel):
class RpcUserProfile(RpcModel):
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I know introducing this new noun ("profile") could be a little confusing. I hope it fits.

I considered naming it something like RpcMinimalUser, but that would mess up the semantics of the "is-a" relationship. That is, RpcUser extending RpcMinimalUser implies "an RpcUser is an RpcMinimalUser", which is wrong because RpcUser is not minimal.

Copy link
Contributor

Choose a reason for hiding this comment

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

Profile seems like a decent name.

Copy link
Member

Choose a reason for hiding this comment

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

I think profile is better than minimal. We have also used Summary for similar result types like OrganizationSummary.

Copy link

codecov bot commented Apr 12, 2024

Codecov Report

Attention: Patch coverage is 92.30769% with 3 lines in your changes are missing coverage. Please review.

Project coverage is 79.72%. Comparing base (ebb08ca) to head (32a65dd).
Report is 3 commits behind head on master.

Additional details and impacted files
@@             Coverage Diff             @@
##           master   #68847       +/-   ##
===========================================
+ Coverage   58.20%   79.72%   +21.51%     
===========================================
  Files        6420     6423        +3     
  Lines      284863   284799       -64     
  Branches    49079    49039       -40     
===========================================
+ Hits       165817   227060    +61243     
+ Misses     118650    57373    -61277     
+ Partials      396      366       -30     
Files Coverage Δ
src/sentry/services/hybrid_cloud/app/impl.py 89.72% <100.00%> (+44.52%) ⬆️
src/sentry/services/hybrid_cloud/filter_query.py 85.96% <100.00%> (+1.75%) ⬆️
src/sentry/services/hybrid_cloud/identity/impl.py 98.41% <100.00%> (+26.98%) ⬆️
src/sentry/services/hybrid_cloud/user/impl.py 87.37% <100.00%> (+41.21%) ⬆️
src/sentry/services/hybrid_cloud/user/model.py 98.16% <100.00%> (+12.18%) ⬆️
...c/sentry/services/hybrid_cloud/user_option/impl.py 97.82% <100.00%> (+15.21%) ⬆️
src/sentry/services/hybrid_cloud/user/serial.py 96.61% <90.00%> (+24.38%) ⬆️
src/sentry/services/hybrid_cloud/user/service.py 85.57% <80.00%> (-0.43%) ⬇️
...entry/services/hybrid_cloud/usersocialauth/impl.py 78.57% <66.66%> (+12.50%) ⬆️

... and 2110 files with indirect coverage changes

@@ -34,12 +34,13 @@ class RpcAuthenticator(RpcModel):
config: Any = None


class RpcUser(RpcModel):
class RpcUserProfile(RpcModel):
Copy link
Member

Choose a reason for hiding this comment

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

I think profile is better than minimal. We have also used Summary for similar result types like OrganizationSummary.

@RyanSkonnord
Copy link
Contributor Author

https://github.com/getsentry/getsentry/pull/13660 should fix the getsentry test failure.

@RyanSkonnord RyanSkonnord merged commit 739c6a6 into master Apr 17, 2024
49 checks passed
@RyanSkonnord RyanSkonnord deleted the efficient-rpc-for-users branch April 17, 2024 19:46
@github-actions github-actions bot locked and limited conversation to collaborators May 3, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Scope: Backend Automatically applied to PRs that change backend components
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants