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

chore: Don't send no-op RPC calls from serializers #77810

Merged
merged 1 commit into from
Sep 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions src/sentry/api/serializers/models/activity.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,11 @@ def __init__(self, environment_func=None):
def get_attrs(self, item_list, user, **kwargs):
# TODO(dcramer); assert on relations
user_ids = [i.user_id for i in item_list if i.user_id]
user_list = user_service.serialize_many(
filter={"user_ids": user_ids}, as_user=serialize_generic_user(user)
)
user_list = []
if user_ids:
user_list = user_service.serialize_many(
filter={"user_ids": user_ids}, as_user=serialize_generic_user(user)
)
users = {u["id"]: u for u in user_list}

commit_ids = {
Expand Down
9 changes: 6 additions & 3 deletions src/sentry/api/serializers/models/group.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,9 +183,12 @@ def _serialize_assignees(self, item_list: Sequence[Group]) -> Mapping[int, Team
for team in Team.objects.filter(id__in=all_team_ids.keys()):
for group_id in all_team_ids[team.id]:
result[group_id] = team
for user in user_service.get_many_by_id(ids=list(all_user_ids.keys())):
for group_id in all_user_ids[user.id]:
result[group_id] = user

user_ids = list(all_user_ids.keys())
if user_ids:
for user in user_service.get_many_by_id(ids=user_ids):
for group_id in all_user_ids[user.id]:
result[group_id] = user

return result

Expand Down
17 changes: 10 additions & 7 deletions src/sentry/api/serializers/models/release.py
Original file line number Diff line number Diff line change
Expand Up @@ -458,13 +458,16 @@ def get_attrs(self, item_list, user, **kwargs):
issue_counts_by_release,
) = self.__get_release_data_with_environments(release_project_envs)

owners = {
d["id"]: d
for d in user_service.serialize_many(
filter={"user_ids": [i.owner_id for i in item_list if i.owner_id]},
as_user=serialize_generic_user(user),
)
}
owners = {}
owner_ids = [i.owner_id for i in item_list if i.owner_id]
if owner_ids:
owners = {
d["id"]: d
for d in user_service.serialize_many(
filter={"user_ids": owner_ids},
as_user=serialize_generic_user(user),
)
}

authors_metadata_attrs = _get_authors_metadata(item_list, user)
release_metadata_attrs = _get_last_commit_metadata(item_list, user)
Expand Down
Loading