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: course details and course statuses APIs #6

Merged
merged 6 commits into from
May 20, 2024

Conversation

shadinaif
Copy link
Collaborator

@shadinaif shadinaif commented Apr 18, 2024

Fixes:

  • fix: Catalog hidden courses are excluded by default
  • fix: use year_of_birth instead of date_of_birth

New:

  • feat: course details and course statuses APIs

Course Details

GET /api/fx/courses/v1/courses?page=<pageNumber>&page_size=<pageSize>&tenant_ids=<tenantIds>&search_text=<searchText>&sort=<sortFields>

<pageNumber> (optional): page number used by pagination. If not passed, the first page will be returned
<pageSize> (optional): page size used by pagination. If not passed, it’ll be assumed as 20 records
<tenantIds> (optional): a comma-separated list of the tenant IDs to get the information for. If not provided, the API will assume the list of all accessible tenants by the user
<searchText> (optional): filter to be used against the course display name and code
<sortFields> (optional): sort the result by the given fields. The default is display_name. The value can be one or more fields, with the use of ( - ) to indicate descending sorting (id, self_paced, enrolled_count, active_count, certificates_count, display_name, org)

Examples:

The first page of the list of courses for all accessible tenants

GET /api/fx/courses/v1/courses

The first page of the list of courses for all accessible tenants, sorted by enrolled_count descending then display_name ascending

GET /api/fx/courses/v1/courses&sort=-enrolled_count,display_name

The second page of the list of courses for all accessible tenants, for those having Sh in the display name or code

GET /api/fx/courses/v1/courses?page=2&search_text=Sh

Course Statuses

GET /api/fx/statistics/v1/course_statuses/?tenant_ids=<tenantIds>

Total number of courses per status of course. There are six possible statuses, which are a composition of enrollment type (instructor-paced and self-paced) with status (ongoing, archived, and upcoming):

  • ongoing: instructor-paced courses that have started but not ended yet
  • archived: instructor-paced courses that have ended
  • upcoming: instructor-paced courses that have not started yet
  • self_ongoing: self-paced courses that have started but not ended yet
  • self_archived: self-paced courses that have ended
  • self_upcoming: self-paced courses that have not started yet

<tenantIds> (optional): a comma-separated list of the tenant IDs to get the information for. If not provided, the API will assume the list of all accessible tenants by the user

Examples:

Courses count in all accessible tenants

GET /api/fx/statistics/v1/course_statuses/

Courses count in tenants 1, 4, and 99

GET /api/fx/statistics/v1/course_statuses/?tenant_ids=1,4,99

@shadinaif shadinaif force-pushed the shadinaif/courses-apis branch 5 times, most recently from 9d60241 to 649888c Compare April 19, 2024 15:31
@shadinaif shadinaif marked this pull request as ready for review April 19, 2024 15:32
@shadinaif shadinaif requested a review from OmarIthawi April 19, 2024 15:32
@shadinaif shadinaif force-pushed the shadinaif/courses-apis branch from 649888c to 9810839 Compare April 19, 2024 15:46
@shadinaif shadinaif force-pushed the shadinaif/courses-apis branch 2 times, most recently from e437a66 to 6e63620 Compare April 19, 2024 16:00
Copy link
Collaborator

@OmarIthawi OmarIthawi left a comment

Choose a reason for hiding this comment

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

@shadinaif please remove or change the active_count to something else. It's the same as enrolled_count.

Comment on lines 55 to 67
enrolled_count=Count(Subquery(
CourseEnrollment.objects.filter(
course_id=OuterRef('id'),
is_active=True,
).values('id')
))
).annotate(
active_count=Count(Subquery(
CourseEnrollment.objects.filter(
course_id=OuterRef('id'),
is_active=True,
).values('id')
))
Copy link
Collaborator

Choose a reason for hiding this comment

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

@shadinaif this is the same result, but with a different name.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

it's the same because the data is not available right now. We'll get it from Clickhouse in another PR. Related issue created

@shadinaif shadinaif force-pushed the shadinaif/courses-apis branch 2 times, most recently from 63fe821 to 365cbb0 Compare April 21, 2024 06:26
@shadinaif shadinaif changed the title feat: course details API feat: course details and course statuses APIs Apr 21, 2024
@shadinaif shadinaif force-pushed the shadinaif/courses-apis branch from 141ca1d to 2a161ca Compare April 21, 2024 11:57
Copy link
Collaborator

@OmarIthawi OmarIthawi left a comment

Choose a reason for hiding this comment

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

Thanks a ton @shadinaif!!

I think this pull request has a bug.



class CourseRatingsView(APIView):
"""View to get the course ratings"""
Copy link
Collaborator

Choose a reason for hiding this comment

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

This says "course ratings" here

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

naming mistake


def get(self, request, *args, **kwargs):
"""
GET /api/fx/statistics/v1/course_ratings/?tenant_ids=<tenantIds>
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same here

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

same mistake

futurex_openedx_extensions/dashboard/views.py Show resolved Hide resolved
@shadinaif shadinaif force-pushed the shadinaif/courses-apis branch from 1e8c7f4 to a5b1fdd Compare April 22, 2024 13:02
@shadinaif shadinaif requested a review from OmarIthawi April 25, 2024 07:28
@OmarIthawi
Copy link
Collaborator

still haven't finished reviewing it, will try to do that do by tomorrow morning

Copy link
Collaborator

@OmarIthawi OmarIthawi left a comment

Choose a reason for hiding this comment

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

Works! Thanks a ton @shadinaif! Let's merge this and ship it to production!

@OmarIthawi
Copy link
Collaborator

@shadinaif this has been deployed to production. Should we merge it?

@shadinaif shadinaif merged commit 35846cc into main May 20, 2024
2 checks passed
@shadinaif shadinaif deleted the shadinaif/courses-apis branch May 20, 2024 10:13
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.

bug: SREI production instance shows all courses count even if they're for testing purposes
2 participants