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

feat: api migration #171

Merged
merged 11 commits into from
Jan 5, 2024
Merged

feat: api migration #171

merged 11 commits into from
Jan 5, 2024

Conversation

volodymyr-chekyrta
Copy link
Contributor

Migration API endpoints from the RG API plugin to the edx-platform upstream.

@openedx-webhooks openedx-webhooks added the open-source-contribution PR author is not from Axim or 2U label Dec 19, 2023
@openedx-webhooks
Copy link

Thanks for the pull request, @volodymyr-chekyrta! Please note that it may take us up to several weeks or months to complete a review and merge your PR.

Feel free to add as much of the following information to the ticket as you can:

  • supporting documentation
  • Open edX discussion forum threads
  • timeline information ("this must be merged by XX date", and why that is)
  • partner information ("this is a course on edx.org")
  • any other information that can help Product understand the context for the PR

All technical communication about the code itself will be done via the GitHub pull request interface. As a reminder, our process documentation is here.

Please let us know once your PR is ready for our review and all tests are green.

@volodymyr-chekyrta volodymyr-chekyrta changed the title DRAFT: feat: api migration feat: api migration Dec 19, 2023
@omerhabib26
Copy link
Contributor

I have started its review

# Conflicts:
#	course/src/main/java/org/openedx/course/presentation/container/CourseContainerFragment.kt
#	course/src/main/java/org/openedx/course/presentation/container/CourseContainerViewModel.kt
Copy link
Contributor

@omerhabib26 omerhabib26 left a comment

Choose a reason for hiding this comment

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

CourseDetailInfo isn't working else only some minor nits.
Suggestion: IMO, For the APIs we can define their versions in Config.yaml.

@@ -6,19 +6,20 @@ import retrofit2.http.*

interface CourseApi {

@GET("/mobile_api_extensions/v1/users/{username}/course_enrollments")
@GET("/api/mobile/v3/users/{username}/course_enrollments/")
Copy link
Contributor

Choose a reason for hiding this comment

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

we can also pass the api_version in params
i.e,

    @GET("/api/mobile/{api_version}/users/{username}/course_enrollments/")
    suspend fun getEnrolledCourses(
        @Header("Cache-Control") cacheControlHeaderParam: String? = null,
        @Path("api_version") apiVersion: String,
        @Path("username") username: String,
        @Query("org") org: String? = null,
        @Query("page") page: Int
    ): CourseEnrollments

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 believe it's a great suggestion 👍👍👍
It might be beneficial to handle this improvement in a separate pull request to include a user API version to the config as well.
What do you think?

Copy link
Contributor

Choose a reason for hiding this comment

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

sure,
@moiz994 can you please create a ticket for these improvements ?

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 create the ticket for now, we will handle it later

core/src/main/java/org/openedx/core/data/api/CourseApi.kt Outdated Show resolved Hide resolved
app/src/main/java/org/openedx/app/AppRouter.kt Outdated Show resolved Hide resolved
@volodymyr-chekyrta
Copy link
Contributor Author

@omerhabib26, thank you for review!
Ready for another pass.

Copy link
Contributor

@omerhabib26 omerhabib26 left a comment

Choose a reason for hiding this comment

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

Only a minor suggestion else LGTM 🚀

@omerhabib26 omerhabib26 self-requested a review January 1, 2024 16:29
Copy link
Contributor

@omerhabib26 omerhabib26 left a comment

Choose a reason for hiding this comment

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

/api/mobile/v3/course_info/ API not working and giving 400

@volodymyr-chekyrta
Copy link
Contributor Author

/api/mobile/v3/course_info/ API not working and giving 400

The API has been changed and PR is now ready for review

Copy link
Contributor

@omerhabib26 omerhabib26 left a comment

Choose a reason for hiding this comment

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

Some APIs are failing in case of course expiry we need to handle them properly

)
}
viewModel.dataReady.observe(viewLifecycleOwner) { isReady ->
if (isReady == true) {
Copy link
Contributor

Choose a reason for hiding this comment

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

This condition doesn't work properly with the expired course and shows an API loading error.
CourseStatusInfo, CourseDates, and Topis API are failing due to course expiry. I guess we can update this change with the following for now. We also need to update the message on NoAccessScreen accordingly. Right now it showing The Course hasn't started yet for every case.

        viewModel.dataReady.observe(viewLifecycleOwner) { coursewareAccess ->
            if (coursewareAccess != null && coursewareAccess.hasAccess) {
                initViewPager()
            } else {
                router.navigateToNoAccess(
                    requireActivity().supportFragmentManager,
                    courseTitle
                )
            }
        }

@@ -36,19 +35,6 @@ import org.openedx.course.R as courseR

class NoAccessCourseContainerFragment : Fragment() {

private var courseTitle = ""
Copy link
Contributor

Choose a reason for hiding this comment

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

I guess we can revert this change and handle it properly

@volodymyr-chekyrta
Copy link
Contributor Author

Some APIs are failing in case of course expiry we need to handle them properly

I know about this case. We encountered a similar problem in the iOS PR openedx/openedx-app-ios#213 and decided to address it in a separate PR.
At the moment, I'm uncertain how to handle this case since we don't have coursewareAccess data.
It's possible that addressing this issue will require modifying the API.
Therefore, I suggest we tackle this later in a separate PR to avoid getting blocked now while waiting for the API.

@volodymyr-chekyrta volodymyr-chekyrta merged commit 42f518a into develop Jan 5, 2024
2 of 3 checks passed
@volodymyr-chekyrta volodymyr-chekyrta deleted the feat/api_migration branch January 5, 2024 09:43
@openedx-webhooks
Copy link

@volodymyr-chekyrta 🎉 Your pull request was merged! Please take a moment to answer a two question survey so we can improve your experience in the future.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
open-source-contribution PR author is not from Axim or 2U
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

5 participants