Skip to content

Commit

Permalink
Merge pull request #498 from openedx/saleem-latif/9420-fixes
Browse files Browse the repository at this point in the history
fix: Remove hyphens from enterprise customer UUID before database query.
  • Loading branch information
saleem-latif authored Sep 16, 2024
2 parents 439eb83 + 5f5d7e8 commit 709f9ba
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 5 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ Unreleased
----------

=========================
[8.12.1] - 2024-09-16
---------------------
* fix: Remove hyphens from enterprise customer UUID before database query.

[8.12.0] - 2024-09-06
---------------------
* refactor: Performance optimizations for enrollments related API endpoints.
Expand Down
2 changes: 1 addition & 1 deletion enterprise_data/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
Enterprise data api application. This Django app exposes API endpoints used by enterprises.
"""

__version__ = "8.12.0"
__version__ = "8.12.1"
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,8 @@ def get_top_courses_enrollments_query(record_count=20):
"""
# Some local environments raise error when course_title is added in SELECT without GROUP BY.
# If you face this issue, you can remove course_title from SELECT.

# TODO: Re-add course_title after testing.
return f"""
SELECT course_key, enroll_type, count(course_key) as enrollment_count
SELECT course_key, course_title , enroll_type, count(course_key) as enrollment_count
FROM fact_enrollment_admin_dash
WHERE enterprise_customer_uuid=%(enterprise_customer_uuid)s AND
enterprise_enrollment_date BETWEEN %(start_date)s AND %(end_date)s
Expand Down
6 changes: 6 additions & 0 deletions enterprise_data/api/v1/views/analytics_enrollments.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ def list(self, request, enterprise_uuid):
"""
Get individual enrollments data for the enterprise.
"""
# Remove hyphens from the UUID
enterprise_uuid = enterprise_uuid.replace('-', '')

serializer = AdvanceAnalyticsQueryParamSerializer(data=request.GET)
serializer.is_valid(raise_exception=True)
min_enrollment_date, _ = FactEnrollmentAdminDashTable().get_enrollment_date_range(
Expand Down Expand Up @@ -122,6 +125,9 @@ def stats(self, request, enterprise_uuid):
2. `top_courses_by_enrollments`: This will show the top courses by enrollments.
3. `top_subjects_by_enrollments`: This will show the top subjects by enrollments.
"""
# Remove hyphens from the UUID
enterprise_uuid = enterprise_uuid.replace('-', '')

serializer = AdvanceAnalyticsEnrollmentStatsSerializer(data=request.GET)
serializer.is_valid(raise_exception=True)

Expand Down
2 changes: 1 addition & 1 deletion enterprise_data/api/v1/views/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ def get_paginated_response(self, request, records, page, page_size, total_count)
(Response): The pagination data.
"""
page_count = math.ceil(total_count / page_size)
if page <= 0 or page > page_count:
if page_count > 0 and (page <= 0 or page > page_count):
raise NotFound('Invalid page.')

return Response({
Expand Down

0 comments on commit 709f9ba

Please sign in to comment.