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

Fix getting the list of available teams per organization #1101

Merged
merged 1 commit into from
Jan 7, 2025

Conversation

suricactus
Copy link
Collaborator

The problem comes from the fact that teamname is a runtime property of the Team class and not an actual database field. In addition we were using Team.object.values() which returns an Iterable[dict], instead of Iterable[Team]. So even if it returned the right type, it would have been terribly slow, due to N+1 situation.

This problem made the /user/<username>/organization return an error, therefore prevented QFieldSync from selecting the available organizations for the team.

The problem comes from the fact that `teamname` is a runtime property of
the `Team` class and not an actual database  field.
In addition we were using `Team.object.values()` which returns an
`Iterable[dict]`, instead of `Iterable[Team]`. So even if it returned
the right type, it would have been terribly slow, due to N+1 situation.

This problem made the `/user/<username>/organization` return an error,
therefore prevented QFieldSync from selecting the available
organizations for the team.
@duke-nyuki
Copy link
Collaborator

@suricactus suricactus requested a review from gounux January 7, 2025 12:09
.select_related("team_organization")
.only("username", "team_organization__username")
)

Copy link
Contributor

Choose a reason for hiding this comment

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

Quick question : do you consider this empty line as necessary ? (l195)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Usually I keep keyword lines separated from the rest of the code, not super hard enforced, but IMO makes it slightly easier to find where the return is.

@suricactus suricactus merged commit e62ed6c into master Jan 7, 2025
13 checks passed
@suricactus suricactus deleted the QF-5030-fix-orgs branch January 7, 2025 22:00
Copy link

sentry-io bot commented Jan 7, 2025

Sentry Issue: QFIELDCLOUD-2ME

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.

3 participants