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

Refactor the role filtering parameter to be a tuple #7020

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

marcospri
Copy link
Member

@marcospri marcospri commented Feb 19, 2025

For:

All method that return a query of users or a roster take a role scope and a role type parameter.

Refactor that to be a tuple of values instead.

This is to accommodate a future change to add new parameter to "exclude" a certain type of role.

This refactor is big enough that deserves its own commit to make it easier to review.

Testing

There should not be any functional changes, for sanity checking navigate around the dashboards.

All method that return a query of users or a roster take a role scope
and a role type parameter.

Refactor that to be a tuple of values instead.

This is to accommodate a future change to add new parameter to "exclude" a certain type of role.

This refactor is big enough that deserves its own commit to make it easier to review.
@marcospri marcospri marked this pull request as draft February 19, 2025 16:13
@marcospri marcospri marked this pull request as ready for review February 20, 2025 08:32
@marcospri marcospri requested a review from mtomilov February 20, 2025 08:40
@@ -219,8 +219,7 @@ def get_assignment_roster(
# If rostering is enabled and we do have the data, use it
query = self._roster_service.get_assignment_roster(
assignment,
role_scope=RoleScope.COURSE,
role_type=RoleType.LEARNER,
include_role=(RoleScope.COURSE, RoleType.LEARNER),
Copy link
Member Author

Choose a reason for hiding this comment

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

Most of the changes is this, from two parameters to a tuple.

I might create a type alias when we add exclude_role.

select(LTIRole.id).where(
LTIRole.scope == role_scope, LTIRole.type == role_type
)
self._filter_membership_by_role_clause(
Copy link
Member Author

Choose a reason for hiding this comment

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

Adding a small helper function here to avoid a bit duplication.

Again, this will make more sense once we add exclude_role, the helper function will do the filtering for both.

Copy link

@mtomilov mtomilov left a comment

Choose a reason for hiding this comment

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

👍

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