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: blocks v2 will filter discussion xblocks #31820

Merged
merged 1 commit into from
Mar 1, 2023
Merged

Conversation

muhammadadeeltajamul
Copy link
Contributor

Mobile app was crashing when discussion xblock was clicked for openedx provider. This change will filter discussion xblocks from blocks v2 api when provider is openedx and request is sent from mobile

Copy link
Contributor

@AhtishamShahid AhtishamShahid left a comment

Choose a reason for hiding this comment

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

We should add a waffle flag for this, and unit tests for the change would be nice to have.

Copy link
Contributor

@saadyousafarbi saadyousafarbi left a comment

Choose a reason for hiding this comment

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

Just a nit. Looks good!

@muhammadadeeltajamul
Copy link
Contributor Author

We should add a waffle flag for this, and unit tests for the change would be nice to have.

I think waffle flag is not needed

Copy link
Contributor

@jawad-khan jawad-khan left a comment

Choose a reason for hiding this comment

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

PR looks good to me
can we add some unit test cases here?

if provider == Provider.OPEN_EDX and request_from_mobile:
blocks = response.data
filtered_blocks = {}
for key, value in blocks.get('blocks', {}).items():
Copy link
Contributor

Choose a reason for hiding this comment

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

just a nit.
response.data = {key: value for key, value in blocks.get('blocks', {}).items() if value.get('type') != 'discussion'}

@muhammadadeeltajamul
Copy link
Contributor Author

PR looks good to me can we add some unit test cases here?

This is the temporary fix to stop mobile application from crashing. Is test case required for this?

"""
configuration = DiscussionsConfiguration.get(context_key=course_key)
provider = configuration.provider_type
if provider == Provider.OPEN_EDX and request_from_mobile:
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we do not need this request_from_mobile condition. If the provider is OPEN_EDX then we do not want to return the discussion xblocks in any case because they are no longer relevant

@muhammadadeeltajamul muhammadadeeltajamul force-pushed the inf-795 branch 2 times, most recently from 7a41b67 to 00eb281 Compare February 28, 2023 07:03
@muhammadadeeltajamul muhammadadeeltajamul requested review from asadazam93 and removed request for jawad-khan February 28, 2023 08:28
Copy link
Contributor

@asadazam93 asadazam93 left a comment

Choose a reason for hiding this comment

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

A couple of nits. Rest looks good

False,
True,
)
def test_filter_discussion_xblocks_for_mobile(self, change_provider):
Copy link
Contributor

Choose a reason for hiding this comment

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

no need to add "for_mobile" here

Copy link
Contributor

Choose a reason for hiding this comment

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

change_provider can be changed to "is_open_edx_provider" for clarity

@edx-pipeline-bot
Copy link
Contributor

EdX Release Notice: This PR has been deployed to the staging environment in preparation for a release to production.

@edx-pipeline-bot
Copy link
Contributor

EdX Release Notice: This PR has been deployed to the production environment.

1 similar comment
@edx-pipeline-bot
Copy link
Contributor

EdX Release Notice: This PR has been deployed to the production environment.

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.

6 participants